AsyncState<T> class sealed

Represents the state of an asynchronous operation.

AsyncState is a sealed class that represents different states of async operations:

Example:

AsyncState<String> state = AsyncLoading<String>();

if (state.isLoading) {
  print('Loading...');
} else if (state.isSuccess) {
  print('Data: ${state.data}');
} else if (state.isError) {
  print('Error: ${state.error}');
}
Implementers

Properties

data → T?
The data from the async operation, if available.
no setter
error Object?
The error from the async operation, if any.
no setter
hashCode int
The hash code for this object.
no setterinherited
isError bool
Whether this state represents an error.
no setter
isLoading bool
Whether this state represents a loading operation.
no setter
isSuccess bool
Whether this state represents a successful operation with data.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTrace StackTrace?
The stack trace from the async operation error, if any.
no setter

Methods

map<R>({R loading()?, R success(T)?, R error(Object?, StackTrace?)?}) → R?
Maps the async state to a value based on its current state.
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