retry<R> method
Executa body, repetindo conforme estas opções.
Implementation
Future<R> retry<R>(Future<R> Function() body) async {
var attempt = 1;
var wait = delay;
final accept = retryIf ?? defaultRetryIf;
while (true) {
try {
return await body();
} catch (e) {
if (attempt >= maxAttempts || !accept(e)) rethrow;
}
attempt++;
await Future<void>.delayed(wait);
final next = wait * backoffFactor;
wait = next > maxDelay ? maxDelay : next;
}
}