request<T> method

  1. @override
Future<Response<T>> request<T>(
  1. String path, {
  2. Object? data,
  3. Map<String, dynamic>? queryParameters,
  4. CancelToken? cancelToken,
  5. Options? options,
  6. ProgressCallback? onSendProgress,
  7. ProgressCallback? onReceiveProgress,
})
inherited

Make HTTP request with options.

Implementation

@override
Future<Response<T>> request<T>(
  String path, {
  Object? data,
  Map<String, dynamic>? queryParameters,
  CancelToken? cancelToken,
  Options? options,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  if (cancelToken != null && cancelToken.isCancelled) {
    throw cancelToken.cancelError!;
  }

  final requestOptions = (options ?? Options()).compose(
    this.options,
    path,
    data: data,
    queryParameters: queryParameters,
    onReceiveProgress: onReceiveProgress,
    onSendProgress: onSendProgress,
    cancelToken: cancelToken,
    sourceStackTrace: StackTrace.current,
  );

  if (_closed) {
    throw DioException.connectionError(
      reason: "Dio can't establish a new connection after it was closed.",
      requestOptions: requestOptions,
    );
  }

  return fetch<T>(requestOptions);
}