getBytes method

Future<(Response, Uint8List)> getBytes(
  1. Uri url, {
  2. Duration timeout = const Duration(seconds: 30),
  3. Map<String, String>? headers,
})

Sends a GET request to the specified url and returns the response as a Uint8List.

Implementation

Future<(http.Response, Uint8List)> getBytes(
  Uri url, {
  Duration timeout = const Duration(seconds: 30),
  Map<String, String>? headers,
}) async {
  final response = await http
      .get(url, headers: headers)
      .handleExceptions(timeout: timeout);
  return (response, response.bodyBytes);
}