Lazy<T extends Object> class
A class that provides lazy initialization for instances of type T.
Isolate sendability
A Lazy is sendable through SendPort iff:
- The
_constructoris a top-level function or a static method (enforced by the@sendablelint at construction sites). - The cached currentInstance, if present, holds a Sync outcome —
Async outcomes wrap an isolate-local
Futureand are not sendable. A freshly-constructed Lazy whose singleton has not yet been read holdsNoneand is unconditionally sendable.
Constructors
-
Lazy(@sendable LazyConstructor<
T> _constructor)
Properties
-
currentInstance
↔ Option<
Resolvable< T> > -
Holds the current singleton instance of type
Tornullif no singleton instance was created.getter/setter pair -
factory
→ Resolvable<
T> -
Returns a new instance of
Teach time, acting as a factory.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
singleton
→ Resolvable<
T> -
Returns the singleton instance currentInstance, or creating it if necessary.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resetSingleton(
) → void -
Resets the singleton instance, by setting currentInstance back to
nullallowing it to be re-created via singleton. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited