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 T is 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 factory for type T which is executed on every resolve call.
registerLazySingleton<T extends Object>(T factory()) → void
Registers a lazy singleton factory for type T. 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 instance for type T, 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 instance for type T.
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