key method

  1. @override
void key(
  1. String key
)
override

A comma goes before each key but the first. The byte before the first key is the { of startObject: no value ends with that byte.

Implementation

@override
void key(String key) {
  bool comma = _length > 0 && _buffer[_length - 1] != 0x7B;
  if (key.length <= _cacheKeyLength) {
    _writeCachedKey(key, key.hashCode & (_cacheSize - 1), comma);
    return;
  }
  _reserve(1);
  if (comma) _buffer[_length++] = _comma;
  _writeString(key);
  _reserve(1);
  _buffer[_length++] = _colon;
}