nextDelay method

Duration nextDelay()

Returns the next backoff delay and advances the attempt counter.

Implementation

Duration nextDelay() {
  final base = initial.inMilliseconds * pow(factor, _attempt);
  final capped = base.clamp(
    initial.inMilliseconds.toDouble(),
    maxDelay.inMilliseconds.toDouble(),
  );
  final jitterMs = capped * jitter * _random.nextDouble();
  _attempt++;
  return Duration(milliseconds: (capped + jitterMs).round());
}