getOrPut<T extends Object> method
T
getOrPut<T extends Object>({
- Object? key,
- required T ifAbsent(
- Lifecycle lifecycle
- LifecycleExtDataOnDestroy<
T> ? onDestroy,
根据Type + key获取,如果不存在则创建信息
Implementation
T getOrPut<T extends Object>({Object? key,
required T Function(Lifecycle lifecycle) ifAbsent,
LifecycleExtDataOnDestroy<T>? onDestroy}) {
final lifecycle = _lifecycle?.target;
if (_isDestroyed || lifecycle == null) {
throw Exception('extData has been destroyed.');
}
return _data
.putIfAbsent(_genKey<T>(key: key),
() => _ExtDataEntry<T>(ifAbsent(lifecycle), onDestroy))
.data;
}