injectFromAncestry<T> method

  1. @protected
T injectFromAncestry<T>(
  1. Object token
)
@protected, inherited

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
T injectFromAncestry<T>(Object token) {
  final result = injectFromAncestryOptional(token);
  if (identical(result, throwIfNotFound)) {
    return throwsNotFound(this, token);
  }
  return unsafeCast<T>(result);
}