AsyncValue<T> class abstract

A wrapper class representing the state of an asynchronous operation.

The AsyncValue<T> class helps manage loading, success, and error states for any asynchronous operation. It provides a structured way to handle and propagate async state in a clean and readable manner.

Usage

Future<AsyncValue<List<User>>> fetchUsers() async {
  return await AsyncValue.guard(() async {
    final users = await api.getUsers();
    return users;
  });
}
Inheritance
Implementers

Constructors

AsyncValue()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

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

Static Methods

guard<T>(Future<T> future()) Future<AsyncValue<T>>
Executes an asynchronous function and wraps its result inside an AsyncValue.