isRetryable static method
Network failures and server errors (5xx) can succeed later; anything else (a 4xx, an event that can't be encoded) will fail the same way again.
Implementation
static bool isRetryable(Object error) {
if (error is NetworkError) return true;
if (error is InvalidResponseError) {
final status = error.statusCode;
return status == null || status >= 500;
}
return false;
}