getDelayForRetry method

Duration getDelayForRetry(
  1. int retryAttempt
)

Calculates the delay for a specific retry attempt using exponential backoff

Implementation

Duration getDelayForRetry(int retryAttempt) {
  if (retryAttempt < 0) return Duration.zero;

  final delayMs = initialDelay.inMilliseconds *
      pow(backoffMultiplier, retryAttempt).toInt();

  final delay = Duration(milliseconds: delayMs);

  // Cap at max delay
  return delay > maxDelay ? maxDelay : delay;
}