getValue method
V
getValue(
- DepAccess<V, D> access
)
override
Implementation
@override
V getValue(DepAccess<V, D> access) {
if (!_registered) {
throw ScopeException(
'You are trying to get an instance of $V '
'from the Dep ${access.name ?? access.id.toString()}, '
'but the Scope ${access.scope._name ?? access.scope.hashCode.toString()} has been disposed. '
'Probably you stored an instance of the Dep '
'somewhere away from the Scope. '
'Do not keep a Dep instance separately from it\'s Scope, '
'and access Dep instance only directly from the Scope.',
);
}
final crtValue = _value;
if (crtValue != null) {
return crtValue.value;
} else {
try {
access.observer?.onValueStartCreate(access.dep);
final newValue = access.builder();
_value = _DepValue(newValue);
access.observer?.onValueCreated(access.dep, newValue);
return newValue;
} on Object catch (e, s) {
access.observer?.onValueCreateFailed(access.dep, e, s);
rethrow;
}
}
}