putIfAbsent method
V
putIfAbsent(
- K key,
- V ifAbsent()
Insert via ifAbsent only when key is absent (or expired). An
explicitly cached null value counts as present.
Implementation
V putIfAbsent(K key, V Function() ifAbsent) {
if (contains(key)) {
return get(key) as V;
}
final value = ifAbsent();
set(key, value);
return value;
}