putIfAbsentAsync method

Future<T> putIfAbsentAsync(
  1. Object? o,
  2. FutureOr<T> ifAbsent()
)

Implementation

Future<T> putIfAbsentAsync(Object? o, FutureOr<T> Function() ifAbsent) {
  if (o == null) {
    return ifAbsent().asFuture;
  }

  var prev = this[o];
  if (prev != null) return prev;

  var ret = ifAbsent().asFuture;
  this[o] = ret;
  return ret;
}