DiContainer class

DiContainer is a data structure that keep all dependencies resolvers

Available Extensions


DiContainer([DiContainer _parent])


hashCode int
The hash code for this object. [...]
read-only, inherited
parent DiContainer
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


addDispose<T>(void disposeFunc(T)) → void
Defines dispose strategy for type T. (It calls for every resolved dependency of type T when container's dispose was invoked
bind<T>() ResolvingContext<T>
Adds dependency resolver of type T to the container. Note that value overwriting within same container is prohibited. If you need it, please use override method instead.
dispose() → void
Disposes all resolved dependencies by the container and clear all dependencies
has<T>() bool
Returns true if this container has dependency resolver for type [T}. If you want to check it for the whole containers tree, use hasInTree instead.
hasInTree<T>() bool
Returns true if the container or it's parents contains dependency resolver for type T. If you want to check it only for this container, use has instead.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
override<T>() ResolvingContext<T>
Overrides dependency resolver for type T in the container
resolve<T extends Object>() → T
Returns resolved dependency defined by type parameter T. Throws StateError if dependency can't be resolved. If you want to get null if dependency can't be resolved, use tryResolve instead
toString() String
A string representation of this object. [...]
tryResolve<T>() → T
Returns resolved dependency of type T or null if it can't be resolved.


operator ==(Object other) bool
The equality operator. [...]