dart_inject library

A very simple and easy to use dependency injection framework for Dart.

Classes

Context
This abstract class is implemented by the internal injection context and provides the interface for registering services.

Functions

resolve<T>({String name}) → T
This function resolves a service determined by the type T and an optional name.
resolveAll<T>() List<T>
This function resolves a service determined by the type T.
shutdown() → void
This function can be called to reset the injection context. Every registered service and all singleton instances will be removed.
startup(InjectionInitializer initializer, {List<String> activeProfiles, Map<String, InjectionInitializer> profileInitializers}) → void
This function must be called at the very beginning of the application to initialize the injection context. The initializer is the one for the gloabl profile. The activeProfiles is a list of all the profile names that are currently activated. When resolving a service, the global profile and the all the activated profiles are used to search a service, where the global propfile has the least priority. The map profileInitializers are the initializers for the differemt know profiles.

Typedefs

InjectionInitializer = void Function(Context)
This the function type definition for the initialization of the available services.
ServiceInitializer<T> = T Function()
This function type defines the signature for functions that initialize a service instances.

Exceptions / Errors

InjectionContextAlreadyInitialized
InjectionContextHasAlreadyService
InjectionContextHasMoreThanOneService
InjectionContextHasNoService
InjectionContextNotInitialized