read method
Reads the bytes at the given range.
When range
is null, the whole content is returned. Out-of-range indexes are clamped to the
available length automatically.
Implementation
@override
Future<ResourceTry<ByteData>> read({IntRange? range}) async {
_bytes ??= await resource.read();
if (range == null) {
return _bytes!;
}
return _bytes!.map((value) {
IntRange range2 =
IntRange(max(0, range.first), min(range.last, value.lengthInBytes));
return value.buffer.asByteData(range2.first, range2.length);
});
}