readFromFile method

  1. @override
Future<Readbuffer> readFromFile(
  1. int length
)
override

Reads the given amount of bytes from the file into the read buffer and resets the internal buffer position. If the capacity of the read buffer is too small, a larger one is created automatically.

@param length the amount of bytes to read from the file. @return true if the whole data was read successfully, false otherwise. @throws IOException if an error occurs while reading the file.

Implementation

@override
Future<Readbuffer> readFromFile(int length) async {
  assert(length > 0);
  Timing timing = Timing(log: _log);
  _resource ??= _ReadBufferFileResource(filename);
  Uint8List _bufferData = await _resource!.read(length);
  Readbuffer result = Readbuffer(_bufferData, _position);
  timing.done(100, "readFromFile position: $_position, length: $length");
  _position += length;
  return result;
}