RetryPolicy class

Pure retry/backoff decisions — no timing, no I/O — so it unit-tests cleanly. Retries network errors, 429, and 5xx with exponential backoff + full jitter, honoring Retry-After.

Constructors

RetryPolicy({int maxRetries = 3, Duration baseDelay = const Duration(milliseconds: 200), Duration maxDelay = const Duration(seconds: 20)})
const

Properties

baseDelay Duration
final
hashCode int
The hash code for this object.
no setterinherited
maxDelay Duration
final
maxRetries int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

backoffCeiling(int attempt) Duration
Deterministic exponential ceiling before jitter.
delay(int attempt, {Duration? retryAfter, double? jitter}) Duration
Final wait. Honors retryAfter when larger; else full jitter. jitter (0..1) is injectable so tests are deterministic.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRetry({required int attempt, int? statusCode, required bool isNetworkError}) bool
attempt is 1-based (1 = the first try that just failed).
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

parseRetryAfter(String? value) Duration?
Parse a Retry-After header (delta-seconds only; HTTP-date ignored).