Encoder constructor
- FlushCallback _flush, {
- required Uint8List buffer,
- int offset = 0,
- int depth = maxDepth,
Encodes into the caller-supplied buffer, draining it through the flush
sink whenever it fills (CORELIB_PLAN §5.1).
buffer is required — a size to allocate from would be a second ownership
model, and §5.1 has only one. offset leaves room at the front for a
framing header. A sink-installed buffer must leave at least
minOutputBuffer bytes after the offset.
Implementation
Encoder(
FlushCallback this._flush, {
required Uint8List buffer,
int offset = 0,
int depth = maxDepth,
}) : _buf = buffer,
_pos = offset,
_flushStart = offset,
_pendingSeq = Int32List(_checkDepth(depth)) {
_checkHandover(buffer.length, offset, streaming: true);
_bufData = ByteData.sublistView(buffer);
_fscratchBytes = _fscratch.buffer.asUint8List();
}