installBuffer method

void installBuffer(
  1. Uint8List buffer, {
  2. int offset = 0,
})

Installs a fresh output buffer mid-stream (typically from inside the flush callback) so encoding continues without interruption (CORELIB_PLAN §5.1).

offset belongs to this installation: writing resumes at that byte of buffer, leaving room at the front for a framing header. The offset is consumed by the installation, so a later flush that the callback returns from without installing anything resumes at 0. Passing the same buffer back is a new installation like any other — that is how a sink re-arms its header room once per flushed packet.

On an encoder with a flush sink the installation must leave at least minOutputBuffer bytes of room (buffer.length - offset); one byte less is rejected right here with SofabError.invalidArgument — the same mechanism as an out-of-range offset — and the encoder keeps writing into the buffer it already had (CORELIB_PLAN §5.1). A buffer installed without a sink is subject to no minimum.

Implementation

void installBuffer(Uint8List buffer, {int offset = 0}) {
  _checkHandover(buffer.length, offset, streaming: _flush != null);
  _buf = buffer;
  _bufData = ByteData.sublistView(buffer);
  _pos = offset;
  _flushStart = offset;
}