InstanceCollection class

Main class to store instances of mvvm elements

Contains internal methods to manage instances

Properties

builders HashMap<String, Function>
final
buildingInstances HashMap<String, List<int>>
final
checkForCyclicDependencies bool
getter/setter pair
container ScopedContainer<MvvmInstance>
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add({required String type, DefaultInputType? params, int? index, String? scope}) → void
Adds instance in collection
addAsync({required String type, DefaultInputType? params, int? index, String? scope}) Future<void>
Adds instance in collection
addBuilder<MInstance extends MvvmInstance>(Function builder) → void
Adds builder for given instance type
addExisting({String scope = BaseScopes.global, required MvvmInstance instance}) → void
Adds existing instance to collection
addTest<MInstance extends MvvmInstance>({String scope = BaseScopes.global, required MvvmInstance instance, dynamic params, bool overrideMainInstance = true}) → void
Adds test instance for given instance type
addUninitialized<InputState>({required String type, InputState? params, int? index, String? scope}) → void
Adds instance in collection
addWithParams<InputState>({required String type, InputState? params, int? index, String? scope}) → void
Adds instance in collection
addWithParamsAsync<InputState>({required String type, InputState? params, int? index, String? scope}) Future<void>
Adds instance in collection
all(String scope) List<MvvmInstance>
Returns all instances in given scope
clear() → void
Utility method to clear collection
constructAndInitializeInstance<MInstance extends MvvmInstance>(String id, {dynamic params, bool withNoConnections = false, void beforeInitialize(dynamic)?}) → MInstance
constructAndInitializeInstanceAsync<MInstance extends MvvmInstance>(String id, {dynamic params, bool withNoConnections = false, void beforeInitialize(dynamic)?}) Future<MInstance>
constructInstance<MInstance extends MvvmInstance>(String id) → MInstance
Returns built instance for given type id
decreaseReferencesInScope(String scope, Type type, {int index = 0}) → void
Decreases reference count in given scope for given type
find<InstanceType>(String scope) → InstanceType?
Tries to find object in scope
finishBuildingInstance(String typeId, int? index) → void
Marks instance and built for cyclic check
forceGet<MInstance extends MvvmInstance>({int? index, String scope = BaseScopes.global}) → MInstance?
Forcibly tries to get instance for type
get<MInstance extends MvvmInstance>({DefaultInputType? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) → MInstance
Return instance for given type
getAllByTypeString(String scope, String type) List<MvvmInstance>
Similar to all but with type provided
getAsync<MInstance extends MvvmInstance>({DefaultInputType? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) Future<MInstance>
Returns instance for given type
getByTypeString({required String type, DefaultInputType? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) MvvmInstance
Similar to get
getByTypeStringWithParams<InputState>({required String type, InputState? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) MvvmInstance
Similar to get
getByTypeStringWithParamsAsync<InputState>({required String type, InputState? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) Future<MvvmInstance>
Similar to get
getInstanceFromCache<MInstance extends MvvmInstance>(String id, {dynamic params, int? index, String scopeId = BaseScopes.global, bool withoutConnections = false}) → MInstance
getInstanceFromCacheAsync<MInstance extends MvvmInstance, InputState>(String id, {dynamic params, int? index, String? scopeId, bool withoutConnections = false}) Future<MInstance>
getUnique<MInstance extends MvvmInstance>({DefaultInputType? params, bool withoutConnections = false}) → MInstance
Similar to get, but create new instance every time
getUniqueAsync<MInstance extends MvvmInstance>({bool withoutConnections = false}) Future<MInstance>
Similar to get, but create new instance every time
getUniqueByTypeString(String type, {DefaultInputType? params, bool withoutConnections = false}) MvvmInstance
Similar to get, but create new instance every time
getUniqueByTypeStringWithParams<InputState>({required String type, InputState? params, bool withoutConnections = false, void beforeInitialize(dynamic)?}) MvvmInstance
Similar to get, but create new instance every time
getUniqueByTypeStringWithParamsAsync<InputState>({required String type, InputState? params, bool withoutConnections = false, void beforeInitialize(dynamic)?}) Future<MvvmInstance>
Similar to get, but create new instance every time
getUniqueWithParams<MInstance extends MvvmInstance, InputState>({InputState? params, bool withoutConnections = false}) → MInstance
Similar to get, but create new instance every time
getUniqueWithParamsAsync<MInstance extends MvvmInstance, InputState>({InputState? params, bool withoutConnections = false}) Future<MInstance>
Similar to get, but create new instance every time
getWithParams<MInstance extends MvvmInstance, InputState>({InputState? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) → MInstance
Return instance for given type
getWithParamsAsync<MInstance extends MvvmInstance, InputState>({InputState? params, int? index, String scope = BaseScopes.global, bool withoutConnections = false}) Future<MInstance>
Return instance for given type
increaseReferencesInScope(String scope, Type type, {int index = 0}) → void
Increases reference count in given scope for given type
mock<MInstance extends MvvmInstance>({MInstance? instance, MInstance builder()?}) → void
Adds mocked builder for given instance type or concrete instance
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performCheckForCyclicDependencies(String typeId, int? index) → void
Checks if object with type id is currently building and throws exception if so
printMap() → void
Utility method to print instances map
prune() → void
Method to remove instances that is no longer used
toString() String
A string representation of this object.
inherited
unregisterInstance<T>({String scope = BaseScopes.global, int? index}) → void
Unregisters instance in scope and resets object reference counter in scope
useAndDisposeInstance<T extends MvvmInstance>(Future body(T)) Future
Helper method to get unique instance and dispose it automatically after body is finished
useAndDisposeInstanceWithParams<T extends MvvmInstance, Input>(Input? params, Future body(T)) Future
Helper method to get unique instance and dispose it automatically after body is finished

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

implementationInstance InstanceCollection
no setter
instance InstanceCollection
no setter

Static Methods

newInstance() InstanceCollection