flush method

void flush(
  1. int offset
)
inherited

Flush the data inside of _curByteData into the _bytesBuilder and allocate a new 1MB of data to _curByteData.

Implementation

void flush(int offset) {
  if (writePosition + offset >= writeByteData.lengthInBytes - 1) {
    /// We take the sublist because otherwise, we would be writing the whole 1MB of this
    /// chunk into the [BytesBuilder] and that would be wasting a lot of space and invalidate
    /// the file.
    bytesBuilder
        .add(writeByteData.buffer.asUint8List().sublist(0, writePosition));
    allocate();
    writePosition = 0;
  }
}