SwiftFuture<T> class
Reactive Future wrapper that tracks loading/error states with retry and error recovery
- Inheritance
-
- Object
- ChangeNotifier
- SwiftFuture
- Available extensions
Constructors
-
SwiftFuture({RetryConfig? retryConfig, T? fallbackValue, Future<
T> recoveryFunction()?, ErrorRecoveryStrategy recoveryStrategy = ErrorRecoveryStrategy.none})
Properties
- currentAttempt → int
-
Current retry attempt (0 = first attempt, 1+ = retries)
no setter
- data → T?
-
The data if successful
no setter
- error → Object?
-
The error if failed
no setter
- errorMessage → String?
-
Get user-friendly error message
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isError → bool
-
Whether the future has errored
no setter
- isLoading → bool
-
Whether the future is currently loading
no setter
- isSuccess → bool
-
Whether the future has completed successfully
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
value
→ AsyncValue<
T> -
Current async state
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
call(
Future< T> future()) → Future<T> - Executes a future and updates state automatically with retry support Rethrows exceptions - use execute for non-throwing version
-
configureRecovery(
{ErrorRecoveryStrategy? strategy, T? fallbackValue, Future< T> recoveryFunction()?}) → void - Configure error recovery
-
configureRetry(
RetryConfig config) → void - Configure retry behavior
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
execute(
Future< T> future()) → Future<void> - Executes a future and updates state automatically with retry support Does not rethrow exceptions - errors are only stored in state
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
notifyListenersTransaction(
) → void -
Available on ChangeNotifier, provided by the TransactionNotifier extension
Notifies listeners, respecting transaction context. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
reset(
) → void - Resets to idle state
-
retry(
) → Future< void> - Retry the last failed operation
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited