evaluate method

FutureOr<bool> evaluate(
  1. DioException error,
  2. int attempt
)

Returns true only if the response hasn't been cancelled or got a bad status code.

Implementation

// ignore: avoid-unused-parameters
FutureOr<bool> evaluate(DioException error, int attempt) {
  bool shouldRetry;
  if (error.type == DioExceptionType.badResponse) {
    final statusCode = error.response?.statusCode;
    if (statusCode != null) {
      shouldRetry = isRetryable(statusCode);
    } else {
      shouldRetry = true;
    }
  } else {
    shouldRetry = error.type != DioExceptionType.cancel &&
        error.error is! FormatException;
  }
  currentAttempt = attempt;
  return shouldRetry;
}