delay method
Returns the delay before the given attempt (0-indexed).
Implementation
@override
Duration delay(int attempt) {
final ms = baseDelay.inMilliseconds * math.pow(2, attempt);
var capped = math.min(ms.toInt(), maxDelay.inMilliseconds);
if (withJitter) {
// Apply ±25 % jitter.
final jitter = (capped * 0.25).toInt();
capped = capped - jitter + _random.nextInt(jitter * 2 + 1);
}
return Duration(milliseconds: capped);
}