addWithParamsAsync<InputState> method
Adds instance in collection
Also calls MvvmInstance.initialize for this isntance
type
- string type of this instance
index
- index for this instance
scope
- string scope to get instance from
params
- params for this instance
Implementation
Future<void> addWithParamsAsync<InputState>({
required String type,
InputState? params,
int? index,
String? scope,
}) async {
final id = type;
final scopeId = scope ?? BaseScopes.global;
if (container.contains(scopeId, id, index) && index == null) {
return;
}
final builder = builders[id];
final newInstance = builder!() as MvvmInstance;
container.addObjectInScope(
object: newInstance,
type: type,
scopeId: scopeId,
);
if (!newInstance.isInitialized) {
newInstance.initialize(params);
await newInstance.initializeAsync();
}
}