AsyncObservable<T> class
A reactive wrapper for managing asynchronous operations and their states.
Provides built-in support for tracking:
- Loading state
- Successful data
- Error messages
Works seamlessly with Observer widgets for automatic UI updates.
Constructors
Properties
- data → T?
-
Current data if the async operation succeeded.
no setter
- error → String?
-
Current error message if the async operation failed.
no setter
- hasData → bool
-
Whether data is available.
no setter
- hasError → bool
-
Whether an error has occurred.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLoading → bool
-
Whether the operation is currently loading.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → AsyncState
-
Current async state (idle, loading, success, error).
no setter
Methods
-
dispose(
) → void - Disposes all underlying observables.
-
execute(
Future< T> operation()) → Future<void> -
Executes an asynchronous
operation
and updates the state accordingly. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Resets the observable to initial idle state.
-
setData(
T data) → void - Sets the value manually and marks state as successful.
-
setError(
String error) → void - Sets the error message manually and marks state as error.
-
toString(
) → String -
A string representation of this object.
inherited
-
watchData(
) → T? - Watches and returns the data reactively.
-
watchError(
) → String? - Watches and returns the error reactively.
-
watchLoading(
) → bool - Watches and returns whether it's currently loading.
-
watchState(
) → AsyncState - Watches and returns the current async state reactively.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited