request method

Future<Response> request(
  1. String method,
  2. String path, {
  3. QueryMap? query,
  4. HeadersInit? headers,
  5. Object? body,
  6. Object? json,
  7. RequestOptions? options,
  8. ProgressCallback? onSendProgress,
  9. ProgressCallback? onReceiveProgress,
})

Implementation

Future<Response> request(
  String method,
  String path, {
  QueryMap? query,
  HeadersInit? headers,
  Object? body,
  Object? json,
  RequestOptions? options,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) {
  final requestHeaders = Headers(headers);
  final requestBody = _normalizeBody(
    body: body,
    json: json,
    headers: requestHeaders,
  );

  final nextOptions = (options ?? const RequestOptions()).copyWith(
    query: query,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  return send(
    Request(
      path,
      RequestInit(
        method: HttpMethod.parse(method),
        headers: requestHeaders,
        body: requestBody,
      ),
    ),
    options: nextOptions,
  );
}