retry method Null safety
- Future<
T> executor(
override
Implementation of the retry mechanism.
Implementation
@override
Future<T> retry(Future<T> Function() executor) async {
try {
var res = await executor();
return res;
} on RateLimitException catch (e) {
attempts++;
if (attempts > 10) {
rethrow;
}
await Future.delayed(getRetryAfter(e.retryAfter));
return retry(executor);
} on TimeoutException catch (e) {
attempts++;
if (attempts > 2) {
rethrow;
}
return retry(executor);
} catch (e) {
rethrow;
}
}