ModulesContainer class final

A container for all the modules of the application.

The ModulesContainer acts as a facade that coordinates between:

  • ProviderRegistry: Manages provider registration and lookup
  • ScopeManager: Manages module scopes and relationships
  • ComposedProviderResolver: Handles composed provider initialization
  • ComposedModuleResolver: Handles composed module initialization

This design makes the container easier to understand and maintain, while keeping the same external API for backwards compatibility.

Constructors

ModulesContainer(ApplicationConfig config)
Creates a new ModulesContainer instance

Properties

allProviders Iterable<Provider>
The providers available in the application
no setter
config ApplicationConfig
The application configuration
final
controllers Iterable<({Controller controller, Module module})>
The list of all the controllers registered in the application
no setter
entrypointToken InjectionToken?
The entrypoint token of the application
no setter
globalInstances Map<InjectionToken, InstanceWrapper>
The list of all the global instances registered in the application
no setter
globalProviders List<Provider>
The list of all the global providers registered in the application
no setter
globalValueProviders Map<ValueToken, Object?>
The map of all the global value providers registered in the application
no setter
hashCode int
The hash code for this object.
no setterinherited
injectableProviders Iterable<Type>
The list of types of providers to inject in the application context
no setter
isInitialized bool
Whether the container has been initialized
no setter
logger Logger
The logger for the module container
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scopes Iterable<ModuleScope>
The list of all the scopes registered in the application
no setter

Methods

canInit(List<Type> providersToInject) List<Type>
Checks if a ComposedProvider can be initialized instantly.
checkResultType(ComposedProvider<Provider> provider, dynamic result, Module module) → void
Checks the result type of a composed provider.
finalize(Module entrypoint) Future<void>
Finalizes the registration of all deferred providers and modules.
generateDependenciesMap(Iterable<Provider> initializedProviders) Map<Type, Provider>
Generates a map of provider types to provider instances.
get<T extends Provider>() → T?
Gets a provider by its type
getAll<T extends Provider>() List<T>
Gets all providers of a specific type
getModuleByProvider(Type provider) Module
Gets the module that registered a provider
getModuleByToken(InjectionToken token) Module
Gets a module by its token
getParents(Module module) List<Module>
Gets all parent modules that import the given module
getScope(InjectionToken token) ModuleScope
Gets the scope of a module by its token
getScopeByProvider(Type provider) ModuleScope
Gets the scope of a module by one of its provider types
initializeComposedModules(Module _) Future<bool>
Initializes composed modules (exposed for backwards compatibility).
initializeComposedProviders() Future<bool>
Initializes composed providers (exposed for backwards compatibility).
initIfUnregistered(Provider provider) Future<void>
Initializes a provider if it implements lifecycle hooks.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerModule(ModuleScope currentScope, {bool internal = false, int depth = 0}) Future<void>
Registers a module in the application.
registerModules(Module entrypoint, {bool internal = false, int depth = 0}) Future<void>
Registers modules starting from an entrypoint module.
resolveProvidersDependencies({bool failOnUnresolved = true}) Future<bool>
Resolves provider dependencies (exposed for backwards compatibility).
toString() String
A string representation of this object.
inherited

Operators

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