ScopedContainer<T> class
final
Simple class to count references for objects
When instances are created we call ScopedContainer.increaseReferencesInScope for each object When instances are disposed ScopedContainer.decreaseReferences called for each object InstanceCollection look up this map to dispose and remove objects that has zero references with InstanceCollection.prune method
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addObjectInScope(
{required T object, required String type, required String scopeId, bool overrideMainInstance = false}) → void - Adds object to given scoped collection
-
all(
String scope) → List< T> - Returns all objects in scope
-
clear(
) → void - Utility method to clear container
-
contains(
String scopeId, String id, int? index) → bool - Checks if container contains object for type in given scope
-
containsBy(
String scopeId, bool compare(T)) → bool - Checks if container contains object for type in given scope by compare function
-
debugPrintMap(
) → void - Utility method to print instances map
-
decreaseReferences(
String scopeId, Type type, {int index = 0}) → void - Substracts 1 to references for given type
-
find<
InstanceType> (String scope) → InstanceType? - Returns first found instance of type in given scope
-
findBy(
String scope, bool compare(T)) → T? - Returns first found instance of type in given scope by compare function
-
getAllByTypeString(
String scope, String type) → List< T> - Similar to get
-
getCurrentReferenceCount(
String scopeId, Type type, {int index = 0}) → int - Returns current reference count for type in given scope
-
getObjectInScope(
{required String type, required String scopeId, int index = 0}) → T? - Returns object in given scope with given index
-
getObjectsInScope(
{required String type, required String scopeId}) → List< T> ? - Returns all objects in given scope
-
increaseReferencesInScope(
String scopeId, Type type, {int index = 0}) → void - Adds 1 to references for given type
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prune(
void onRemove(T)) → void - Method to remove instances that is no longer used
-
referencesInScope(
String scopeId, Type type) → List< int> - Returns references list for given scope and type
-
removeObjectInScope(
{required String type, required String scopeId, int? index, required void onRemove(T)}) → void - Removes object in given scope
-
removeObjectReferenceInScope(
{required Type type, required String scopeId, int? index}) → void - Removes object in given scope
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited