Component class

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

Example: import 'coffee_shop.inject.dart';

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

  CoffeeMaker get coffeeMaker;
}

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

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

The framework generates a concrete class CoffeeShop$Component 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$Component.create. This is not strictly necessary, but useful to hide the generated code from the call sites.

Constructors

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

Properties

hashCode int
The hash code for this object.
no setterinherited
modules List<Type>
Modules supplying providers for the component.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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