Inject<T> class

A class that represents an injection of a dependency.

An injection can be of three types: factory, singleton, and lazySingleton. The type of injection is determined by the type parameter passed to the constructor.

The Inject class has three factory constructors: Inject.factory, Inject.singleton, and Inject.lazySingleton. Each constructor creates an instance of Inject with the corresponding InjectType.

The get method returns the value of the injected dependency. If the injection is of type factory, the value is always recomputed. If the injection is of type singleton or lazySingleton, the value is computed only once and cached for future use.

The injected dependency is computed by calling the _call function passed to the constructor. The _call function takes a FlutterInjections instance as a parameter and returns an instance of type T.

Example usage:

final myInject = Inject.singleton((i) => MyDependency());
final myDependency = myInject.get(myFlutterInjections);

Constructors

Inject.new(Bind<T> _call, {InjectType type = InjectType.lazySingleton})
Inject.factory(Bind<T> _call)
factory
Inject.lazySingleton(Bind<T> _call)
factory
Inject.singleton(Bind<T> _call)
Factory to create a singleton bind
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type InjectType
final
value ↔ T?
getter/setter pair

Methods

dispose() → void
get(FlutterInjections i) → T
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