delayForAttempt method

Duration delayForAttempt(
  1. int attempt
)

Calculates the delay for a specific attempt using exponential backoff.

Formula: min(initialDelay * 2^attempt, maxDelay)

Implementation

Duration delayForAttempt(int attempt) {
  final exponentialDelay = initialDelay * (1 << attempt);
  return exponentialDelay > maxDelay ? maxDelay : exponentialDelay;
}