addKey method

void addKey(
  1. String value
)

This methods adds a key to a map and should be followed by an add... value call.

It also implies that you call this method only after you called startMap.

Implementation

void addKey(String value) {
  _integrityCheckOnKeyAddition();
  if (_keyCache.containsKey(value)) {
    _stack.add(_keyCache[value]!);
    return;
  }
  final utf8String = utf8.encode(value);
  final length = utf8String.length;
  final keyOffset = _offset;
  final newOffset = _newOffset(length + 1);
  _pushBuffer(utf8String);
  _offset = newOffset;
  final stackValue =
      _StackValue.withOffset(keyOffset, ValueType.Key, BitWidth.width8);
  _stack.add(stackValue);
  _keyCache[value] = stackValue;
}