byteData method
Reads content body as bytes and returns a future of ByteData.
Optional start
and end
parameters define a range to be read. It's
required that 0 ≤ start ≤ end ≤ contentLength
. See also
ByteData.sublistView
for reference.
Implementation
@override
Future<ByteData> byteData([int start = 0, int? end]) async {
try {
final res = response;
if (res is http.StreamedResponse) {
return ByteData.sublistView(await res.stream.toBytes(), start, end);
} else {
return ByteData.sublistView(
(res as http.Response).bodyBytes,
start,
end,
);
}
} on Exception catch (e) {
throw ClientException.readingBytesFailed(e);
}
}