shouldRetry method
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);
}