putIfAbsent method

V putIfAbsent(
  1. K key,
  2. V ifAbsent()
)

Put if absent

Implementation

V putIfAbsent(K key, V Function() ifAbsent) {
  final newMap = Map<K, V>.from(value);
  final sizeBefore = newMap.length;
  final result = newMap.putIfAbsent(key, ifAbsent);
  if (sizeBefore != newMap.length) value = newMap;
  return result;
}