operator [] method

V operator [](Object key)

Returns the value for the given key or null if key is not in the map.

Some maps allows keys to have null as a value, For those maps, a lookup using this operator does cannot be used to distinguish between a key not being in the map, and the key having a null value. Methods like containsKey or putIfAbsent can be use if the distinction is important.

Source

V operator [](Object key) {
  if (!_validKey(key)) return null;
  if (_root != null) {
    int comp = _splay(key as dynamic/*=K*/);
    if (comp == 0) {
      return _root.value;
    }
  }
  return null;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-collection/SplayTreeMap/operator_get.html