RetryExponential class
Exponential backoff retry policy: delay increases exponentially with each attempt
The delay is calculated as: baseDelay * (multiplier ^ attempt)
Example:
final limit = fLimit(2);
await limit(
() => fetchData(),
retry: RetryExponential(
maxAttempts: 5,
baseDelay: Duration(seconds: 1),
multiplier: 2.0,
maxDelay: Duration(seconds: 30),
),
);
// Delays: 1s, 2s, 4s, 8s (capped at maxDelay)
- Inheritance
-
- Object
- RetryPolicy
- RetryExponential
Constructors
- RetryExponential({required int maxAttempts, required Duration baseDelay, double multiplier = 2.0, Duration maxDelay = const Duration(minutes: 1)})
- Creates an exponential backoff retry policy
Properties
- baseDelay → Duration
-
Base delay for the first retry
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxAttempts → int
-
Maximum number of attempts (including the initial attempt)
final
- maxDelay → Duration
-
Maximum delay cap to prevent excessive waits
final
- multiplier → double
-
Multiplier applied to delay for each subsequent retry
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
nextDelay(
int attempt, Object error, StackTrace stackTrace) → Duration? -
Returns the delay before the next retry, or null for immediate retry
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
shouldRetry(
int attempt, Object error, StackTrace stackTrace) → bool -
Whether the task should be retried
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited