RetryDelay class sealed
How long to wait before the next attempt after a failure — the
retryDelay option. Only consulted when RetryPolicy decided to retry.
Default: RetryDelay.defaultValue: one second, then two, four, …, never more than thirty seconds (the same numbers as TanStack Query).
retryDelay: RetryDelay.defaultValue // 1s, 2s, 4s, … max 30s
retryDelay: const RetryDelay.fixed(Duration(seconds: 2))
retryDelay: const RetryDelay.exponential(
base: Duration(milliseconds: 200),
maximum: Duration(seconds: 5),
)
retryDelay: RetryDelay.dynamic(
(failureCount, error) => error is RateLimited
? error.retryAfter
: const Duration(seconds: 1),
)
- Annotations
Constructors
- RetryDelay.dynamic(Duration compute(int failureCount, Object error))
-
Computed per failure (TanStack Query:
retryDelay: (attempt, error) => ms).failureCountis how many attempts had failed before the one that just did, so it is0before the first retry. Named like StaleTime.dynamic and RefetchInterval.dynamic, the other values computed on demand.constfactory - RetryDelay.exponential({Duration base, Duration maximum})
-
Doubles from
baseon every failure and never exceedsmaximum. With no arguments this is defaultValue: one second, two, four, … capped at thirty.constfactory - RetryDelay.fixed(Duration delay)
-
The same wait before every retry (TanStack Query:
retryDelay: ms).constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
int failureCount, Object error) → Duration -
The wait before the next attempt, after an attempt threw
errorwithfailureCountfailures before it. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultValue → const RetryDelay
-
The default:
min(1s * 2^failureCount, 30s)— one second, two, four, … capped at thirty.