asynchronous top-level constant

Asynchronous const asynchronous

Annotates a module provider method that returns a Future.

Such a provider is referred to as asynchronous provider. Asynchronous providers are resolved from futures into dependency instances prior to returning the component to the application.

For example: @module abstract class CarModule { @provides @asynchronous Future

class Dealership {
  @inject
  Dealership(Car car);
}

Note that in the example Dealership depends on Car rather than Future<Car>. This is the quintessential property of the asynchronous annotation. It guarantees that Future<Car> is resolved into Car prior to instantiating objects that depend on it.

If you wish to inject the Future itself without resolving it, simply omit this annotation and the Future will be treated as a normal type, and the framework will not attempt to resolve it.

For example: @module abstract class CarModule { @provides Future

class Dealership {
  @inject
  Dealership(Future<Car> car);
}

Implementation

const asynchronous = Asynchronous._();