getLocalInstance<T extends MvvmInstance> method
Returns connected instance of given type
index
- index of instance if multiple are connected
Implementation
T getLocalInstance<T extends MvvmInstance>({int index = 0}) {
if (_instances[T] == null) {
throw IllegalStateException(
message: 'Instance $T is not connected.',
);
}
if (index < 0 || index >= _instances[T]!.length) {
throw IllegalArgumentException(
message:
'The index = $index value must be non-negative and less than count of instances of $T.',
);
}
return _instances[T]![index] as T;
}