scope library
Classes
- GlobalScope
- Experimental. Use with caution as the api is likely to change. This is intended as a replacement for Get It but with a consistent api to Scope as well as being sensitive to ScopeKeys in Scope. Values injected into a GlobalScope by injecting the same key into a Scope.
- Scope
- Creates a Scope providing dependency injection to your call stack.
-
ScopeKey<
T> - The only purpose of ScopeKeys is to be globally unique so that they can be used to uniquely identify injected values. ScopeKeys are opaque – you are not supposed to read any other information from them except t heir identity.
Functions
-
hasScopeKey<
T> (ScopeKey< T> key) → bool -
Returns true if
key
is contained within the current Scope or an ancestor Scope -
isNullable<
T> () → bool -
Returns true if
T
was declared as a nullable type (e.g. String?) -
isWithinScope(
) → bool - Returns true if the caller is running within a Scope
-
use<
T> (ScopeKey< T> key, {T withDefault()?}) → T -
Returns the value injected for
key
Exceptions / Errors
-
CircularDependencyException<
T> - Thrown by use when called inside a Scope.single or Scope.sequence callback and the keys factories try to mutually inject each other.
-
DuplicateDependencyException<
T> - Thrown if an attempt is made to inject the same ScopeKey twice into the same Scope.
-
MissingDependencyException<
T> -
Thrown by use when no value has been registered in the Scope
for
_key
and it has no default value.