GetIt class

Very simple and easy to use service locator You register your object creation or an instance of an object with registerFactory, registerSingleton or registerLazySingleton And retrieve the desired object using get or call your loactor das as function as its a callable class

Constructors

GetIt()

Properties

allowReassignment ↔ bool
By default it's not allowed to register a type a second time. If you really need to you can disable the asserts by settingallowReassignment= true
read / write
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

call<T>([String instanceName ]) → T
get<T>([String instanceName ]) → T
retrives or creates an instance of a registered type T depending on the registration function used for this type.
registerFactory<T>(FactoryFunc<T> func, [ String instanceName ]) → void
registers a type so that a new instance will be created on each call of get on that type T type to register func factory funtion for this type instanceName if you provide a value here your factory gets registered with that name instead of a type. This should only be nesseary if you need to register more than one instance of one type. Its highly not recommended
registerLazySingleton<T>(FactoryFunc<T> func, [ String instanceName ]) → void
registers a type as Singleton by passing a factory function that will be called on the first call of get on that type T type to register func factory funtion for this type instanceName if you provide a value here your factory gets registered with that name instead of a type. This should only be nesseary if you need to register more than one instance of one type. Its highly not recommended
registerSingleton<T>(T instance, [ String instanceName ]) → void
registers a type as Singleton by passing an instance of that type that will be returned on each call of get on that type T type to register instanceName if you provide a value here your instance gets registered with that name instead of a type. This should only be nesseary if you need to register more than one instance of one type. Its highly not recommended
reset() → void
Clears all registered types. Handy when writing unit tests
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited