readBatchInto method

  1. @override
Future<List<int>> readBatchInto(
  1. List<ReadIntoRange> ranges
)

Implementation

@override
Future<List<int>> readBatchInto(List<ReadIntoRange> ranges) async {
  _checkOpen();
  if (ranges.isEmpty) return [];
  final response = await _submit('readCountedRanges', {
    'ranges': [
      for (final r in ranges) [r.offset, r.destination.length],
    ],
  }) as List;
  final data = Uint8List.view(
    (response[0] as TransferableTypedData).materialize(),
  );
  final counts = (response[1] as List).cast<int>();
  var position = 0;
  for (var i = 0; i < ranges.length; i++) {
    final destination = ranges[i].destination;
    destination.setRange(0, counts[i], data, position);
    position += destination.length;
  }
  return counts;
}