CancelableRetry<T> class

Utility for wrapping an asynchronous function in automatic retry logic with ability to cancel it.

Allows to automatically retry request on some condition. Retry logic implemented with exponential back-off, useful when making requests over network. If you don't need to continue retry - you can cancel retry. In such case last result will be returned.

Constructors

CancelableRetry(FutureOr<T> request(), {required FutureOr<bool> retryIf(T), Duration delayFactor = const Duration(milliseconds: 200), Duration maxDelay = const Duration(seconds: 30), int maxAttempts = 8, double randomizationFactor = 0.25})

Properties

delayFactor Duration
final
hashCode int
The hash code for this object.
no setterinherited
isRunning bool
Returns true if retry is running.
no setter
maxAttempts int
final
maxDelay Duration
final
randomizationFactor double
final
request FutureOr<T> Function()
final
retryIf FutureOr<bool> Function(T)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel() Future<void>
Cancels retries.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() Future<T>
Runs request and returns result.
toString() String
A string representation of this object.
inherited

Operators

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