RetryPolicy constructor

const RetryPolicy({
  1. int maxRetries = 3,
  2. Duration initialDelay = const Duration(seconds: 1),
  3. Duration maxDelay = const Duration(seconds: 60),
  4. double jitter = 0.1,
})

Creates a RetryPolicy.

maxRetries must be >= 0 and jitter must be between 0.0 and 1.0. initialDelay should be positive and maxDelay should be >= initialDelay (not enforced via asserts to preserve const constructability, since Duration operations are not const-evaluable).

Implementation

const RetryPolicy({
  this.maxRetries = 3,
  this.initialDelay = const Duration(seconds: 1),
  this.maxDelay = const Duration(seconds: 60),
  this.jitter = 0.1,
}) : assert(maxRetries >= 0, 'maxRetries must be >= 0'),
     assert(jitter >= 0.0 && jitter <= 1.0, 'jitter must be 0.0 - 1.0');