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 {
  List<int> range = validateRange(start, length);
  start = range[0];
  length = range[1];

  if (_data.isEmpty) {
    return Stream.empty();
  }
  Stream<List<int>> stream = Stream.fromFuture(
      Future.value(_data.sublist(start, start + length - 1)));
  return stream;
}