LazyRef<K, V> class

A lazy-loaded reference to a value.

LazyRef wraps a value that may not be loaded yet. The value is loaded on first access according to the configured strategy.

Constructors

LazyRef(K key, Future<V> fetcher(K key), {Duration? ttl})
Creates a LazyRef.

Properties

hashCode int
The hash code for this object.
no setterinherited
isExpired bool
Whether the value has expired based on TTL.
no setter
isLoaded bool
Whether the value has been loaded.
no setter
key → K
The key for this reference.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
ttl Duration?
TTL for the cached value.
final
value → V?
The current value, or null if not loaded.
no setter

Methods

get() Future<V>
Gets the value, loading it if necessary.
invalidate() → void
Invalidates the cached value, forcing a reload on next access.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reload() Future<V>
Forces a reload of the value.
toString() String
A string representation of this object.
inherited

Operators

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