use<T> function

T use<T>(
  1. ScopeKey<T> key, {
  2. T withDefault()?,
})

Returns the value provided for key, or the keys default value if no value was provided.

A MissingDependencyException will be thrown if the passed key is not in scope.

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);