read method

  1. @override
Future<Stream<List<int>>> read({
  1. int? start,
  2. int? length,
})
override

Reads from start offset a maximum amount of length bytes. If start is null, then starts from the beginning of the data. If length is null, then reads up to the end.

Implementation

@override
Future<Stream<List<int>>> read({int? start, int? length}) async {
  IntRange? range;
  if (start != null || length != null) {
    List<int> validatedRange = validateRange(start, length);
    start = validatedRange[0];
    length = validatedRange[1];
    range = IntRange(start, start + length - 1);
  }

  Stream<List<int>>? stream =
      await _package.extractStream(_entry.filename, range: range);
  if (stream == null) {
    throw DataStreamException.readError(
        "Can't read file at ${_entry.filename}");
  }
  return stream;
}