nextDelay method

  1. @override
Duration? nextDelay(
  1. int attempt,
  2. Object error,
  3. StackTrace stackTrace
)
override

Returns the delay before the next retry, or null for immediate retry

attempt is the current attempt number (0-based for first attempt). error is the error that caused the failure. stackTrace is the stack trace of the error.

Implementation

@override
Duration? nextDelay(int attempt, Object error, StackTrace stackTrace) {
  final delayMs = baseDelay.inMilliseconds * (multiplier.pow(attempt));
  final cappedMs = delayMs.round().clamp(0, maxDelay.inMilliseconds);
  return Duration(milliseconds: cappedMs);
}