getInstance<V extends T> method
V?
getInstance<V extends T>({
- V ifAbsentPut()?,
Returns the instance corresponding to the generic type V
, or null
.
If the value is absent and an ifAbsentPut
function is provided,
populates the map with the result of said function.
Implementation
V? getInstance<V extends T>({V Function()? ifAbsentPut}) {
final value = _map[V];
if (value == null) {
if (ifAbsentPut == null) {
return null;
} else {
return _map[V] = ifAbsentPut();
}
} else {
return value as V;
}
}