createRequest static method

Future<HttpClientRequest> createRequest(
  1. String method,
  2. String url, {
  3. Map<String, String>? headers,
})

Creates an HttpClientRequest with the given parameters. method is the HTTP method. url is the URL to make the request to. headers specifies additional headers to set.

Implementation

static Future<HttpClientRequest> createRequest(
  String method,
  String url, {
  Map<String, String>? headers,
}) async {
  var request = await client.openUrl(method, Uri.parse(url));
  if (headers != null) {
    headers.forEach(request.headers.set);
  }
  return request;
}