putValueIfAbsent method

bool putValueIfAbsent(
  1. K key,
  2. V value
)

Inserts value only if key is not already present.

Returns true if the value was inserted, false otherwise.

Implementation

bool putValueIfAbsent(K key, V value) {
  var inserted = false;

  _map.putIfAbsent(key, () {
    inserted = true;
    _map2[value] = key;
    return value;
  });

  return inserted;
}