delayForAttempt method

Duration delayForAttempt(
  1. int attempt
)

Implementation

Duration delayForAttempt(int attempt) {
  if (attempt < 1) {
    throw RangeError.range(attempt, 1, null, 'attempt');
  }
  if (initialDelay == Duration.zero) return Duration.zero;

  final multiplier = pow(backoffFactor, attempt - 1).toDouble();
  final microseconds = (initialDelay.inMicroseconds * multiplier).round();
  return Duration(microseconds: min(microseconds, maxDelay.inMicroseconds));
}