Injector class abstract

Dependency injection container.

Constructors

Injector({required BindFunc bindFunc, String? name, Injector? parent})
Creates an Injector from it's bindings.
factory
Injector.empty({String? name})
Creates an empty Injector.
factory
Injector.fromModule({required Module module, String? name, Injector? parent})
Creates an Injector from a Module.
factory
Injector.fromModules({required Iterable<Module> modules, String? name, Injector? parent})
Creates an Injector from a list of Module instances.
factory

Properties

bindings Iterable<Binding>
Gets a list of all the Binding instances attached to this Injector.
no setter
disposed bool
disposed will be true if this object was disposed
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
name String
The name of the injector.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

child() InjectorBuilder
contains<T>({String? name}) bool
Checks whether the container has a given binding.
dispose() → void
Disposes this Injector which will clear all the dependencies and call Disposable.dispose on all singletons implementing the Disposable interface.
override
disposeInstance() → void
Override this method to provide dispose logic for the concrete object.
inherited
get<T>({String? name, Params? params}) → T
Gets a dependency from the container with optional name and params.
getOptional<T>({String? name, Params? params}) Optional<T>
Gets an Optional to handle if the registration doesn't exist.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

builder() InjectorBuilder
Creates a InjectorBuilder to create Injector instances.