CachedValue<CacheContentType> class abstract

A value container that caches values resultant from a potentially expensive operation.

It is convenient for storing values that:

  • Are computed from other values;
  • Can be changed given known and unknown conditions;
  • Should not be computed on every access;

See also:

Constructors

CachedValue(ComputeCacheCallback<CacheContentType> callback)
A shorthand to CachedValue.simple.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isValid bool
Check the current state of the cache.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → CacheContentType
Access the most current cache value.
no setter

Methods

invalidate() → void
Marks the cache as invalid.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh() → CacheContentType
Updates the cache to an updated state.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

dependent<A, B>({required ComputeCacheDependency<B> on, required ComputeCacheCallback<A> compute}) → ComputedCachedValue<A, B>
Creates a CachedValue that its validity is defined by a dependency.
simple<CacheContentType>(ComputeCacheCallback<CacheContentType> callback) → SimpleCachedValue<CacheContentType>
Creates a CachedValue that is only manually invalidated. The main CachedValue constructor is a shorthand for this method.