read method
Implementation
@override
Future<Uint8List> read(int offset, int count) async {
final int safe = clampCount(offset, count);
if (safe == 0) return Uint8List(0);
try {
final Response response = await _client.get(Uri.parse(url), headers: <String, String>{..._headers, "Range": "bytes=$offset-${offset + safe - 1}"}).timeout(uDocNetworkTimeout);
if (response.statusCode != 206 && response.statusCode != 200) {
throw UDocError(code: UDocErrorCode.network, message: "Unexpected status ${response.statusCode}", path: url);
}
final Uint8List bytes = response.bodyBytes;
return bytes.length > safe ? Uint8List.sublistView(bytes, 0, safe) : bytes;
} on TimeoutException {
throw UDocError(code: UDocErrorCode.timeout, message: "Range request timed out", path: url);
}
}