AsyncValue<T> class
sealed
Result of an async operation tracked by useFuture.
This is a sealed class similar to AsyncSnapshot with four possible states:
- AsyncIdle: No connection, no data
- AsyncLoading: Waiting for data
- AsyncData: Has data
- AsyncError: Has error
Unlike AsyncSnapshot, this is a sealed class that enables exhaustive pattern matching.
- Implementers
Constructors
- AsyncValue.data(T data)
-
Creates a data state with the result.
constfactory
- AsyncValue.error(Object error, [StackTrace? stackTrace])
-
Creates an error state.
constfactory
- AsyncValue.idle()
-
Creates an idle state (no connection).
constfactory
- AsyncValue.loading()
-
Creates a loading state (waiting).
constfactory
Properties
- dataOrNull → T?
-
Returns the data if available, null otherwise.
no setter
- errorOrNull → Object?
-
Returns the error if available, null otherwise.
no setter
- hasData → bool
-
Whether there is data or error available.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isData → bool
-
Whether the operation completed successfully (ConnectionState.done with
data).
no setter
- isError → bool
-
Whether the operation failed (has error).
no setter
- isIdle → bool
-
Whether the operation hasn't started yet.
no setter
- isLoading → bool
-
Whether the operation is in progress (ConnectionState.waiting).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stackTraceOrNull → StackTrace?
-
Returns the stack trace if available, null otherwise.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited