RetryPolicy class sealed
How many times a task may run, and how long to wait between failures.
maxAttempts counts executions, not extra retries. A policy with
maxAttempts: 1 runs once and does not retry.
delayAfter receives the number of attempts that have already started.
After attempt 1 fails, the queue waits delayAfter(1, ...).
Computed delays are capped at maxSchedulableDelay so a retry cannot overflow DateTime.
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxAttempts → int
-
Total executions allowed for a task, including the first.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
delayAfter(
int completedAttempts, double randomFraction) → Duration -
Delay before the next attempt after
completedAttemptshave started. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Serializes this policy so it can be stored with the task.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
exponential(
{required int maxAttempts, required Duration initialDelay, Duration? maxDelay, bool jitter = false, double jitterFactor = 0.2}) → RetryPolicy -
Doubles
initialDelayafter each failure, up tomaxDelay. -
fixed(
{required int maxAttempts, required Duration delay}) → RetryPolicy -
Waits the same
delaybetween attempts. -
fromJson(
Map< String, dynamic> json) → RetryPolicy - Restores a policy produced by toJson.
-
none(
) → RetryPolicy - Runs the task once. Further failures are permanent.
Constants
- maxSchedulableDelay → const Duration
- Largest delay the scheduler will store.