write method

void write(
  1. List<int> data, {
  2. int? offset,
})

Write data starting at position (or offset if given). Cannot grow the blob — throws RangeError if the write would extend past the current length. Advances the cursor by data.length.

Implementation

void write(List<int> data, {int? offset}) {
  if (!_writable) {
    throw StateError('BlobHandle is read-only');
  }
  final b = _backing();
  final from = offset ?? _offset;
  if (from < 0 || from + data.length > b.length) {
    throw RangeError('write of ${data.length} bytes at offset $from exceeds '
        'blob length ${b.length}; sqlite incremental blob I/O '
        'cannot grow the blob');
  }
  b.setRange(from, from + data.length, data);
  _offset = from + data.length;
}