injectFromSelf<T> method

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

Injects and returns an object representing token from this injector.

Unlike inject, this only checks this itself, not the parent or the ancestry of injectors. This is equivalent to constructor parameters annotated with @Self.

Throws an error if token was not found.

Implementation

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