shouldRetry method
attempt is 1-based (1 = the first try that just failed).
Implementation
bool shouldRetry({required int attempt, int? statusCode, required bool isNetworkError}) {
if (attempt > maxRetries) return false;
if (isNetworkError) return true;
if (statusCode == null) return false;
return statusCode == 429 || (statusCode >= 500 && statusCode <= 599);
}