ControlFactory class

Main singleton class. Factory is used for dependency injection and to store objects.

Control provides most used methods statically. Only rarely is necessary to use Factory directly. Use Control.factory to get instance of this Factory.

It's preferred to use more powerful Control.initControl to initialize and fill this Factory.

Mixed in types
Available Extensions

Properties

debug bool
Runtime debug value. Default value is false.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Checks if Factory is initialized. Use onReady to listen initialize completion.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add<T>({Type? key, required InitFactory<T> init}) → void
Stores init Factory for later use - ControlFactory.init or ControlFactory.get.
call<T>({dynamic key, dynamic args, bool withInjector = true}) → T?
Callable class
clear() bool
Clears whole Factory - all stored objects, initializers and injector. Also BaseLocalization, ControlBroadcast and ControlRoute is removed and cleared/disposed.
contains(dynamic value) bool
Checks if key/type/object is in Factory.
containsKey(dynamic key) bool
Checks if given key is in Factory. Looks to store and initializers.
containsType<T>() bool
Checks if Type is in Factory. Looks to store and initializers.
dispose() → void
Used to clear and dispose object. After this method call is object typically unusable and ready for GC. Can be called multiple times!
override
findInitializer<T>([Type? key]) InitFactory<T?>?
Finds and returns InitFactory of given Type.
get<T>({dynamic key, dynamic args, bool withInjector = true}) → T?
Returns object of requested type by given key or by Type from ControlFactory. When args are not empty and object is Initializable, then Initializable.init is called. Set withInjector to re-inject stored object.
init<T>({Type? key, dynamic args}) → T?
Returns new object of requested Type via initializer in ControlFactory. When args are not null and initialized object is Initializable then Initializable.init is called.
initialize({Map? entries, Map<Type, InitFactory>? factories, Injector? injector, Future initAsync()?}) bool
Initializes Factory and given objects.
inject<T>(dynamic item, {dynamic args, bool withInjector = true, bool withArgs = true}) → void
Injects and initializes given item with args. Set withInjector to inject given object. Set withArgs to init given object.
keyOf<T>({dynamic key, dynamic value}) → dynamic
Resolve key for given args.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onReady() Future<void>?
Completes when Factory is initialized including async load (localization, prefs, etc.).
printDebugStore({bool items = true, bool initializers = true}) → void
registerModule(ControlModule module, {bool includeSubModules = false}) → void
remove<T>({dynamic key, bool dispose = false}) int
Removes specific object with given key or by Type from ControlFactory. When given key is null, then key is T - check ControlFactory.keyOf for more info. If object of given key is not found, then all instances of T are removed. Set dispose to dispose removed object/s.
removeInitializer(Type key) bool
Removes initializer of given key. Returns true if initializer is removed.
resolve<T>(dynamic source, {dynamic key, dynamic args, T? defaultValue}) → T?
Executes sequence of functions to retrieve expected object. Look up in source for item via Parse.getArg and if object is not found then ControlFactory.get is executed with given key and args. Returns object from source or from factory store/initializers or defaultValue.
set<T>({dynamic key, required dynamic value}) → dynamic
Stores value with given key in ControlFactory. Object with same key previously stored in factory is overridden. When given key is null, then key is T or generated from Type of given value - check ControlFactory.keyOf for more info. Returns key of stored value.
setInjector(Injector? injector) → void
Sets Injector for this Factory. Set null to remove current Injector.
swap<T>({dynamic key, required dynamic value, bool dispose = false}) → void
Swaps value in Factory by given key or Type. When given key is null, then key is T - check ControlFactory.keyOf for more info.
swapInitializer<T>(InitFactory<T> initializer) → void
Swaps initializers in Factory. Basically calls ControlFactory.removeInitializer and ControlFactory.add.
toString() String
A string representation of this object.
override

Operators

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