postBytes method

Future<(Response, Uint8List)> postBytes(
  1. (Uri, Map<String, String>) composedRequest, {
  2. Duration timeout = const Duration(seconds: 30),
  3. Map<String, String>? headers,
  4. Encoding? encoding,
})

Sends a POST request to the specified url and returns the response as a JSON object.

Implementation

Future<(http.Response, Uint8List)> postBytes(
  (Uri, Map<String, String>) composedRequest, {
  Duration timeout = const Duration(seconds: 30),
  Map<String, String>? headers,
  Encoding? encoding,
}) async {
  final url = composedRequest.$1;
  final body = composedRequest.$2;
  final response = await http
      .post(
        url,
        headers: headers,
        body: body,
        encoding: encoding,
      )
      .handleExceptions(timeout: timeout);
  return (response, response.bodyBytes);
}