module top-level constant

Module const module

Annotates a class as a collection of providers for dependency injection.

A class annotated with module is a class that can be used to insert dependencies into the object graph. Modules may extend or mixin other modules, or rely on composition to fill in dependencies. Methods can have parameters that are in the object graph and will be invoked with the objects created from the Component the module is installed on.

An example:

@module
class CarModule {
  @provides
  Car provideCar(Manufacturer manufacturer) =>
      Car(manufacturer: manufacturer, year: 2019);
}

In this instance, an component that includes CarModule will know how to provide an instance of Car, given that all parameters of provideCar are satisfied in the final object graph.

Implementation

const module = Module._();