getDelayForAttempt method

Duration getDelayForAttempt(
  1. int attempt
)

Calculate delay for a given retry attempt

Implementation

Duration getDelayForAttempt(int attempt) {
  if (attempt <= 0) return Duration.zero;

  final delay = Duration(
    milliseconds: (initialDelay.inMilliseconds *
                  (backoffMultiplier * attempt)).round(),
  );

  return delay > maxDelay ? maxDelay : delay;
}