Google is committed to advancing racial equity for Black communities. See how.

encode method

  • @override

void encode (Encoder encoder, String value, int offset) override

Implementation

@override
void encode(Encoder encoder, String value, int offset) {
  validate(value);
  if (value == null) {
    encoder
      ..encodeUint64(0, offset) // size
      ..encodeUint64(kAllocAbsent, offset + 8); // data
    return null;
  }
  final bytes = Utf8Encoder().convert(value);
  final int size = bytes.length;
  encoder
    ..encodeUint64(size, offset) // size
    ..encodeUint64(kAllocPresent, offset + 8); // data
  int childOffset = encoder.alloc(size);
  _copyUint8(encoder.data, bytes, childOffset);
}