putIfAbsent method

V putIfAbsent(
  1. double frame,
  2. K key,
  3. V ifAbsent()
)

If frame doens't change, look up the value of key, or add a new entry if it isn't there. In other way removes all entries from the map.

Returns the value associated to key, if there is one. Otherwise calls ifAbsent to get a new value, associates key to that value, and then returns the new value.

Implementation

V putIfAbsent(double frame, K key, V Function() ifAbsent) {
  if (this.frame != frame) {
    this.frame = frame;
    state.clear();
  }

  final putIfAbsent = state.putIfAbsent(key, ifAbsent);
  return putIfAbsent;
}