withRetry method
Implementation
Future<T> withRetry({
int maxRetries = 3,
Duration delay = const Duration(seconds: 1),
}) async {
int retries = 0;
while (retries < maxRetries) {
try {
return this;
} catch (e) {
retries++;
if (retries == maxRetries) {
rethrow;
}
await Future.delayed(delay);
}
}
throw Exception("Retry failed");
}