putIfAbsent method

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

Look up the value associated with key, or add a new value if it isn't there. The pair is promoted to the MRU position.

Otherwise calls ifAbsent to get a new value, associates key to that value, and then returns the new value, with the key-value pair in the MRU position. If this causes length to exceed maximumSize, then the LRU position is removed.


V putIfAbsent(K key, V Function() ifAbsent) {
  final entry =
      _entries.putIfAbsent(key, () => _createEntry(key, ifAbsent()));
  if (length > maximumSize) {
  return entry.value;