Injector class

Annotates an abstract class used as a blueprint to generate an injector.

Example:

import 'coffee_shop.Injector.dart';

@Injector(const [DripCoffeeModule])
abstract class CoffeeShop {
  static final create = CoffeeShop$Injector.create;

  CoffeeMaker get coffeeMaker;
}

main() async {
  var coffeeShop = await CoffeeShop.create(new DripCoffeeModule());
  print(coffeeShop.coffeeMaker.brewCoffee());
}

In the example, we define an injector class CoffeeShop, which provides a CoffeeMaker. It uses DripCoffeeModule as a source of dependency providers for the injector.

The framework generates a concrete class CoffeeShop$Injector that has a static asynchronous function named create, which takes DripCoffeeModule as an argument and returns a Future<CoffeeShop>.

CoffeeShop defines static final create as a convenience accessor to CoffeeShop$Injector.create. This is not strictly necessary, but useful to hide the generated code from the call sites.

Constructors

Injector([List<Type> modules])
const
factory

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
modules List<Type>
Modules supplying providers for the injector. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

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