retryTransientFailures static method
Default predicate: retry transport failures, timeouts and 5xx responses, but only for methods that are safe to repeat.
POST and PATCH are excluded because replaying them can duplicate work. Pass a custom retryIf to opt them in.
Implementation
static bool retryTransientFailures(ApiResponse response, int attempt) {
if (!_isIdempotent(response.request.method)) return false;
final status = response.statusCode;
return status == ApiResponse.transportFailure ||
status == 408 ||
status == 429 ||
(status >= 500 && status <= 599);
}