AsyncState<T> class
An immutable snapshot of an asynchronous value with explicit loading/error states — the shape every data screen renders. Carries optional data even while LoadStatus.loading or LoadStatus.error so the UI can show last-known content (e.g. cached nodes) under a spinner or error banner.
Constructors
- AsyncState.error(AppError error, {T? data})
-
Failed with
error, optionally retaining priordata.const - AsyncState.idle()
-
Nothing loaded yet.
const
- AsyncState.loading({T? data, bool stale = false})
-
A load is in flight, optionally over existing
data(which may bestale).const - AsyncState.ready(T data)
-
Loaded
datasuccessfully.const
Properties
- data → T?
-
The current value, if any.
final
- error → AppError?
-
The failure when status is LoadStatus.error.
final
- hasData → bool
-
Whether a value is present.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLoading → bool
-
Whether a load is currently running.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stale → bool
-
Whether data is known-stale (e.g. served from cache pending a refresh).
final
- status → LoadStatus
-
The current status.
final
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