add method

V? add(
  1. K key,
  2. V value
)

Implementation

V? add(K key, V value) {
  if (this == null) return null;
  V? result;
  if (this!.containsKey(key)) {
    result = this!.update(key, (_) => value);
  } else {
    result = this!.putIfAbsent(key, () => value);
  }
  return result;
}