AsyncValue<T> class sealed

A class that represents a value that is loaded asynchronously. It can be in one of the following states:

Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
isData bool
Returns true if this is AsyncData.
no setter
isError bool
Returns true if this is AsyncError.
no setter
isIdle bool
Returns true if this is AsyncIdle.
no setter
isIdleOrLoading bool
Returns true if this is AsyncIdle or AsyncLoading.
no setter
isLoading bool
Returns true if this is AsyncLoading.
no setter
lastData → T?
Returns the last data that was successfully loaded This is useful when the current state is AsyncError or AsyncLoading
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setLastData(T? value) → void
This is useful when manually hanlding async state and you want to keep track of the last successful data. You can use the lastData getter to retrieve the last successful data when in AsyncError or AsyncLoading state.
toString() String
A string representation of this object.
inherited
unwrap() → T
Casts this AsyncValue to AsyncData and return it's value or throws CastError if this is not AsyncData.
unwrapOrNull() → T?
If this is AsyncData, returns it's value. Otherwise returns null.

Operators

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

Static Methods

tryCatch<T>(Future<T> future(), {WritableBeacon<AsyncValue<T>>? beacon, T? optimisticResult}) Future<AsyncValue<T>>
Executes the future provided and returns AsyncData with the result if successful or AsyncError if an exception is thrown.