cancel method

void cancel([
  1. Object? reason
])

Cancel the request with the given reason.

Implementation

void cancel([Object? reason]) {
  _cancelError = DioException.requestCancelled(
    requestOptions: requestOptions ?? RequestOptions(),
    reason: reason,
    stackTrace: StackTrace.current,
  );
  if (!_completer.isCompleted) {
    _completer.complete(_cancelError);
  }
}