getConstantEncoder function
Returns an encoder that always writes a predefined constant byte sequence.
This encoder ensures that encoding always produces the specified byte array, ignoring any input values.
Implementation
FixedSizeEncoder<void> getConstantEncoder(Uint8List constant) {
return FixedSizeEncoder<void>(
fixedSize: constant.length,
write: (_, bytes, offset) {
bytes.setAll(offset, constant);
return offset + constant.length;
},
);
}