read method

  1. @override
Future<ResourceTry<ByteData>> read(
  1. {IntRange? range}

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.


Future<ResourceTry<ByteData>> read({IntRange? range}) async {
  _bytes ??= await _bytesFunction();
  if (range == null) {
    return ResourceTry.success(_bytes!);
  IntRange range2 =
      IntRange(max(0, range.first), min(range.last, _bytes!.lengthInBytes));
  return ResourceTry.success(
      _bytes!.buffer.asByteData(range2.first, range2.length));