RetryInterceptor constructor

RetryInterceptor({
  1. required Dio dio,
  2. void logPrint(
    1. String message
    )?,
  3. int retries = 3,
  4. List<Duration> retryDelays = const [Duration(seconds: 1), Duration(seconds: 3), Duration(seconds: 5)],
  5. RetryEvaluator? retryEvaluator,
  6. bool ignoreRetryEvaluatorExceptions = false,
  7. Set<int> retryableExtraStatuses = const {},
})

Implementation

RetryInterceptor({
  required this.dio,
  this.logPrint,
  this.retries = 3,
  this.retryDelays = const [
    Duration(seconds: 1),
    Duration(seconds: 3),
    Duration(seconds: 5),
  ],
  RetryEvaluator? retryEvaluator,
  this.ignoreRetryEvaluatorExceptions = false,
  this.retryableExtraStatuses = const {},
}) : _retryEvaluator = retryEvaluator ??
          DefaultRetryEvaluator({
            ...defaultRetryableStatuses,
            ...retryableExtraStatuses,
          }).evaluate {
  if (retryEvaluator != null && retryableExtraStatuses.isNotEmpty) {
    throw ArgumentError(
      '[retryableExtraStatuses] works only if [retryEvaluator] is null.'
          ' Set either [retryableExtraStatuses] or [retryEvaluator].'
          ' Not both.',
      'retryableExtraStatuses',
    );
  }
  if (retries < 0) {
    throw ArgumentError(
      '[retries] cannot be less than 0',
      'retries',
    );
  }
}