AsyncValue<T> class
sealed
A class that represents a value that is loaded asynchronously. It can be in one of the following states:
- AsyncIdle - the initial state
- AsyncLoading - when the value is being loaded
- AsyncData - when the value is successfully loaded
- AsyncError - when an error occurred while loading the value
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isData → bool
-
Returns
trueif this is AsyncData.no setter - isError → bool
-
Returns
trueif this is AsyncError.no setter - isIdle → bool
-
Returns
trueif this is AsyncIdle.no setter - isIdleOrLoading → bool
-
Returns
trueif this is AsyncIdle or AsyncLoading.no setter - isLoading → bool
-
Returns
trueif 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
lastDatagetter 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
CastErrorif 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< ? beacon, T? optimisticResult}) → Future<T> >AsyncValue< T> > - Executes the future provided and returns AsyncData with the result if successful or AsyncError if an exception is thrown.