injectFromAncestry<T> method
Injects and returns an object representing token
from ancestors.
Unlike inject
, this only checks instances registered with any ancestry
injector, not this injector. This is equivalent to the constructor
parameters annotated with @SkipSelf
.
Throws an error if token
was not found.
Implementation
@protected
@nonVirtual
T injectFromAncestry<T>(Object token) {
final result = injectFromAncestryOptional(token);
if (identical(result, throwIfNotFound)) {
throw errors.noProviderError(token);
}
return unsafeCast(result);
}