exponentialBackoff static method
Implementation
static Duration? exponentialBackoff(int failedAttempts) {
// Do not retry more than 5 times.
if (failedAttempts > 5) return null;
// Wait for 2^(failedAttempts-1) seconds, before retrying.
// i.e. 1 second, 2 seconds, 4 seconds, ...
return Duration(seconds: 1 << (failedAttempts - 1));
}