RetryDelayFn typedef
Function signature for dynamic retry delay calculation
Receives the current retry attempt (0-indexed) and the error that occurred. Returns the duration to wait before the next retry attempt.
Example:
// Custom delay based on error type
retryDelayFn: (attempt, error) {
if (error is RateLimitException) {
return Duration(seconds: 60); // Wait 1 minute for rate limits
}
return Duration(milliseconds: 200 * (attempt + 1)); // Linear backoff
}
Implementation
typedef RetryDelayFn = Duration Function(int attempt, Object error);