DiContainer class
A container for registering and retrieving dependencies.
Constructors
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
-
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
-
clear(
) → void - Clears all registered instances.
-
get<
T> () → T? -
Retrieves an instance of type
T
. If the instance is a factory function, it will invoke the factory. -
register<
T> (T instance) → void -
Registers an instance of type
T
.T
is the type of the instance, andinstance
is the instance itself. -
registerFactory<
T> (T factory()) → void -
Registers a factory function that creates an instance of type
T
. The factory is executed when get<T>() is called for the first time. -
registerLazySingleton<
T> (T factory()) → void - Registers a lazy singleton instance, which is created only when get<T>() is called.
-
registerSingleton<
T> (T factory()) → void -
Registers a singleton instance of type
T
, meaning the same instance is used each time get<T>() is called.