get<T> method

T get<T>({
  1. dynamic qualifier,
})

Retrieves T from the scope with its provider. Throws if a provider is not available for T.

Implementation

T get<T>({dynamic qualifier}) {
  Scope? scope = this;
  Provider? provider;
  final handle = DependencyHandle(T, qualifier);
  while (scope != null) {
    provider = scope._providers[handle];
    if (provider != null) break;
    scope = scope._parentScope;
  }
  if (provider == null) {
    throw Exception(
        "The type $T with the qualifier $qualifier doesn't have any provider in the current scope.");
  }
  return provider.provide(this);
}