AsyncValue<T> class sealed

A sealed union representing the state of an asynchronous operation.

Every async workflow transitions through these states:

  • AsyncLoading — the operation is in progress (optionally carries the previous successful value for optimistic UI).
  • AsyncData — the operation completed successfully with a T result.
  • AsyncError — the operation failed with an error and stackTrace.

Use when for exhaustive pattern matching, or the convenience getters isLoading, hasData, hasError, valueOrNull, and requireValue for quick checks.

Equality: all three variants implement value == / hashCode. ZenithNode.set therefore skips notifications when you write an equal AsyncValue again (e.g. AsyncData(sameUser)). To re-notify listeners without changing the payload, call ZenithNode.invalidate — do not rely on a duplicate ZenithNode.set.

Implementers
Annotations

Properties

hasData → bool
Whether this value holds successful data.
no setter
hasError → bool
Whether this value represents a failed operation.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasValue → bool
Alias for whether valueOrNull is non-null.
no setter
isLoading → bool
Whether this value is currently loading.
no setter
requireValue → T
Returns the current value, throwing a StateError if no data is available.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
valueOrNull → T?
The most recent successful value, or null if no data has arrived yet.
no setter

Methods

maybeWhen<R>({R data(T data)?, R loading(T? previousData)?, R error(Object error, StackTrace stackTrace)?, required R orElse()}) → R
Pattern-matches with an orElse fallback for unhandled states.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
when<R>({required R data(T data), required R loading(T? previousData), required R error(Object error, StackTrace stackTrace)}) → R
Exhaustively pattern-matches all three async states.
whenOrNull<R>({R data(T data)?, R loading(T? previousData)?, R error(Object error, StackTrace stackTrace)?}) → R?
Pattern-matches and returns null for unhandled states.

Operators

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