writeIterable method Null safety

  1. @override
void writeIterable(
  1. Iterable iterable
)
override

Writes a Iterable into the buffer

  • iterable: the value to write

Implementation

@override
void writeIterable(Iterable iterable) {
  final length = iterable.length;

  if (length <= 0xF) {
    writeUint8(0x90 | length);
  } else if (length <= 0xFFFF) {
    writeUint8(types.array16);
    writeUint16(length);
  } else if (length <= 0xFFFFFFFF) {
    writeUint8(types.array32);
    writeUint32(length);
  } else {
    throw MsgPackOverflowError(
        'Array is too big to be serialized with msgpack');
  }

  for (final item in iterable) {
    write(item);
  }
}