ObjectCache class

A simple cache of objects, where is possible to define different instantiators for each key.

Constructors

ObjectCache([int? maxInstances])

Properties

hashCode int
The hash code for this object.
no setterinherited
maxInstances int?
Maximum number of cached instances.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clear all cached instances and all definitions.
clearInstances() → void
Removes all cached instances, preseving definitions.
define<O>(String key, O instantiator(), [bool cacheValidator(Object o)?]) → void
Defines instantiator and cache-validator for key.
defineAll(Map<String, dynamic> map) → void
Define all keys from map, where map values can be a instantiator functions or a list with 2 values (instantiator and cache-validator functions).
disposeInstance(String key) → void
Removes key instance from cache.
disposeInstances(int? amountToRemove) int
get<O>(String key, [O instantiator()?, bool cacheValidator(Object o)?]) → O?
Returns an object for key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setCacheValidator<O>(String key, bool cacheValidator(Object o)) → void
Sets the cacheValidator for key
setInstantiator<O>(String key, O instantiator()) → void
Sets the instantiator for key
toString() String
A string representation of this object.
inherited
undefine<O>(String key) → void
Remove instantiator and cache-validator for key.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String key) → dynamic