writeBinary method

  1. @override
void writeBinary(
  1. Uint8List buffer
)
override

Writes a Uint8List into the buffer

  • buffer: the value to write

Implementation

@override
void writeBinary(Uint8List buffer) {
  final length = buffer.length;
  if (length <= 0xFF) {
    writeUint8(types.bin8);
    writeUint8(length);
  } else if (length <= 0xFFFF) {
    writeUint8(types.bin16);
    writeUint16(length);
  } else if (length <= 0xFFFFFFFF) {
    writeUint8(types.bin32);
    writeUint32(length);
  } else {
    throw MsgPackOverflowError(
        'Data is too long to be serialized with msgpack.');
  }
  writeBytes(buffer);
}