request<T> method

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

Make http request with options.

path The url path. data The request data options The request options.

Implementation

@override
Future<Response<T>> request<T>(
  String path, {
  data,
  Map<String, dynamic>? queryParameters,
  CancelToken? cancelToken,
  Options? options,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  options ??= Options();
  var requestOptions = options.compose(
    this.options,
    path,
    data: data,
    queryParameters: queryParameters,
    onReceiveProgress: onReceiveProgress,
    onSendProgress: onSendProgress,
    cancelToken: cancelToken,
  );
  requestOptions.onReceiveProgress = onReceiveProgress;
  requestOptions.onSendProgress = onSendProgress;
  requestOptions.cancelToken = cancelToken;

  if (_closed) {
    throw DioError(
      requestOptions: requestOptions,
      error: "Dio can't establish new connection after closed.",
    );
  }

  return fetch<T>(requestOptions);
}