get method
override
Returns the value associated with key
.
Implementation
Future<V> get(K key, {Loader<K, V> ifAbsent}) async {
if (_map.containsKey(key)) {
return _map[key];
}
// If this key is already loading then return the existing future.
if (_outstanding.containsKey(key)) {
return _outstanding[key];
}
if (ifAbsent != null) {
var futureOr = ifAbsent(key);
_outstanding[key] = futureOr;
var v = await futureOr;
_map[key] = v;
_outstanding.remove(key);
return v;
}
return null;
}