use<T> function
Returns the value injected for key
The key is searched for in the following order and the first value is returned.
- the hierarchy of Scopes
- the GlobalScope.
- check if
withDefault
was passed a value - check if the
key
passed a default to ScopeKey
A MissingDependencyException will be thrown if the passed key
is not in any scope and no defaults were found.
A CircularDependencyException will be thrown if a circular dependency is discovered values provided by Scope.single or Scope.sequence.
Implementation
T use<T>(ScopeKey<T> key, {T Function()? withDefault}) =>
_use(key, withDefault: withDefault);