addKey method

  1. @override
bool addKey(
  1. String key
)
inherited

Add key to collection.

If a key does not allready exists then it is mapped to an empty value collection, otherwise no change occurs.

Returns true if key did not already exist, false otherwise.

Throws ArgumentError if key is empty or null.

Throws ArgumentError if keyMapping(key) is empty or null.

Implementation

@override
bool addKey(String key) {
  final addResult = _add(_root, _mapKeyNonEmpty(key).runes.toList(), null);

  _root = addResult.rootNode;

  // Change only occurs if key is new
  if (addResult.newKey) {
    _version.value.incKeysVersion();
  }

  return addResult.newKey;
}