Lazy<T> class
A class that provides lazy object initialization.
The value is initialized by the initializer function only when being called for the first time.
Example of use:
class Service {
final int id;
Service(this.id);
}
Lazy<Service> example = lazy(() => Service(10));
Lazy value can be accessed by call or value getter
print(example().id);
print(example.value.id);
Constructors
-
Lazy(Initializer<
T> _initializer)
Properties
- hashCode → int
-
The hash code for this object.
read-onlyoverride
- isInitialized → bool
-
Returns whether the value has already been initialized or not.
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- value → T
-
Get the lazily initialized value.
read-only
Methods
-
call(
) → T -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator.
override