retryDelayFn property

RetryDelayFn? retryDelayFn
final

Custom function to calculate retry delay based on attempt and error

If provided, this function will be called instead of using the default exponential backoff calculation. Receives the retry attempt (0-indexed) and the error that occurred.

Example - Error-aware delays:

retryDelayFn: (attempt, error) {
  if (error is RateLimitException) {
    return Duration(seconds: 60); // Wait longer for rate limits
  }
  if (error is NetworkException) {
    return Duration(seconds: 5); // Quick retry for network issues
  }
  return Duration(milliseconds: 200 * (attempt + 1)); // Default
}

Implementation

final RetryDelayFn? retryDelayFn;