shouldRetry method

  1. @override
bool shouldRetry(
  1. int attempt,
  2. int? statusCode,
  3. Object? error
)
override

Returns true if another attempt should be made after attempt attempt failed with the given statusCode or error.

attempt — 1-based attempt counter (1 = first attempt just failed). statusCode — HTTP status code of the last response, or null. error — exception thrown by the adapter, or null.

Implementation

@override
bool shouldRetry(int attempt, int? statusCode, Object? error) {
  if (attempt >= maxAttempts) return false;
  if (statusCode != null) return retryOnStatusCodes.contains(statusCode);
  return error != null && RetryPolicy.isTransientError(error);
}