DependencyContainer class
Centralized dependency injection container for registering and resolving services.
Constructors
- DependencyContainer()
-
Returns the singleton instance of DependencyContainer.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
isRegistered<
T extends Object> () → bool -
Checks whether type
Tis registered in the container. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerFactory<
T extends Object> (T factory()) → void -
Registers a factory function
factoryfor typeTwhich is executed on every resolve call. -
registerLazySingleton<
T extends Object> (T factory()) → void -
Registers a lazy singleton
factoryfor typeT. The factory will be invoked only when resolve is called for the first time. -
registerMock<
T extends Object> (T instance) → void -
Registers a mock or override
instancefor typeT, bypassing normal duplicate check. This is intended for unit testing or dynamic service swapping. -
registerSingleton<
T extends Object> (T instance) → void -
Registers a pre-instantiated singleton
instancefor typeT. -
reset(
) → void - Resets all registered factories and singletons in the container.
-
resolve<
T extends Object> () → T -
Resolves the registered instance or factory for type
T. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited