get method

Future<V> get(
  1. K key
)

Get the value identified by key. If this is called with a key that is equivalent to one that is currently being loaded, a identical Future identical to the one returned for the prior call will be returned.

Implementation

Future<V> get(K key) => _pending.putIfAbsent(key, () async {
      try {
        return await create(key);
      } finally {
        final check = _pending.remove(key);
        assert(check != null);
        // This finally block is guaranteed to execute after the Future
        // created by the ifAbsent function has been stored in _pending,
        // because the await in the try block always suspends the function.
        // See the Dart language specification, version 2.10, section 17.33
        // (https://dart.dev/guides/language/specifications/DartLangSpec-v2.10.pdf).
      }
    });