CustomAutoInjector class

Custom implementation of AutoInjectorImpl that adds replacement functionality.

Uses UUID for unique tag generation to avoid conflicts between injectors.

Implemented types

Constructors

CustomAutoInjector.new([void on(AutoInjector injector)?])
Creates a CustomAutoInjector with a random UUID tag.
factory
CustomAutoInjector.tag(String tag, void on(AutoInjector injector)?)
Creates a CustomAutoInjector with a specific tag and optional configuration.

Properties

bindLength int
Only test
no setterinherited
binds List<Bind>
finalinherited
committed bool
getter/setter pairinherited
disposeListeners List<VoidCallback>
finalinherited
hashCode int
The hash code for this object.
no setterinherited
injectorsList List<AutoInjectorImpl>
finalinherited
layersGraph → LayersGraph
finalinherited
on → void Function(AutoInjector injector)?
Helps with instance registration
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tag String
final

Methods

add<T>(Function constructor, {BindConfig<T>? config, String? key}) → void
Register a factory instance. A new instance will be generated whenever requested.
inherited
addBind<T>(Bind<T> bind) → void
inherited
addDisposeListener(VoidCallback callback) → void
Run the callback when method dispose is called.
All the dispose callbacks are called before the injector is disposed.
inherited
addInjector(covariant AutoInjectorImpl injector) → void
Inherit all instances and transforms from other AutoInjector object.
inherited
addInstance<T>(T instance, {BindConfig<T>? config, String? key}) → void
Register a instance. A concrete object (Not a function).
inherited
addLazySingleton<T>(Function constructor, {BindConfig<T>? config, String? key}) → void
Register a LazySingleton instance. It will generate a single instance for the duration of the application, or until manually removed.
The object will be started only when requested the first time.
inherited
addSingleton<T>(Function constructor, {BindConfig<T>? config, String? key}) → void
Register a Singleton instance. It will generate a single instance for the duration of the application, or until manually removed.
The object will be started as soon as it is registered.
inherited
call<T>({ParamTransform? transform, String? key}) → T
Request an instance by Type
transform: Transform a param. This can be used for example to replace an instance with a mock in tests.
When key is provided it will search the instance that have the same key
inherited
commit() → void
Informs the container that the additions are finished and the injector is ready to be used.
This command starts the singletons.
inherited
dispose([void instanceCallback(dynamic instance)?]) → void
Remove all the binds and turns the injector uncommitted
inherited
disposeInjectorByTag(String injectorTag, [void instanceCallback(dynamic instance)?]) → void
Find the injector by injectorTag in the layers tree and execute "dispose()" on it
inherited
disposeRecursive() → void
Execute "dispose()" in all the injectors from this layers tree
inherited
disposeSingleton<T>({String? key}) → T?
Removes the singleton instance.
This does not remove it from the registry tree.
When key is provided it will search the instance that have the same key
inherited
get<T>({ParamTransform? transform, String? key}) → T
Request an instance by Type
transform : Transform a param. This can be used for example to replace an instance with a mock in tests.
When key is provided it will search the instance that have the same key
inherited
getNotifier<T>({String? key}) → dynamic
Request an notifier property by Type
When key is provided it will search the instance that have the same key
inherited
isAdded<T>({String? key}) bool
Checks if the instance record exists.
When key is provided it will search the instance that have the same key
inherited
isInstantiateSingleton<T>({String? key}) bool
checks if the instance registration is as singleton.
When key is provided it will search the instance that have the same key
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeDisposeListener(VoidCallback callback) → void
Remove the callback previous included using addDisposeListener.
If the callback was NOT included previously using addDisposeListener it will not do anything.
inherited
replace<T>(T instance, {String? key}) → void
Replaces an existing dependency with a new instance.
override
replaceInstance<T>(T instance, {String? key}) → void
Replaces an instance record with a concrete instance.
This function should only be used for unit testing.
Any other use is discouraged.
When key is provided it will search the instance that have the same key
inherited
startSingletons() → void
inherited
toString() String
A string representation of this object.
inherited
tryGet<T>({ParamTransform? transform, String? key}) → T?
Request an instance by Type that when throwing an exception returns null.
transform: Transform a param. This can be used for example to replace an instance with a mock in tests.
When key is provided it will search the instance that have the same key
inherited
uncommit() → void
remove commit
inherited

Operators

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