injectFromParent<T> method

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

Injects and returns an object representing token from the parent.

Unlike inject, this only checks instances registered directly with the parent injector, not this injector, or further ancestors. This is equivalent to constructor parameters annotated with @Host.

Throws an error if token was not found.

Implementation

@protected
T injectFromParent<T>(Object token) {
  final result = injectFromParentOptional(token);
  if (identical(result, throwIfNotFound)) {
    return throwsNotFound(this, token);
  }
  return unsafeCast<T>(result);
}