GenerateInjector class

Annotates a method to generate an Injector factory at compile-time.

Using @GenerateInjector is conceptually similar to using @Component or @Directive with a providers: const [ ... ] argument, or to creating a an injector at runtime with ReflectiveInjector, but like a component or directive that injector is generated ahead of time, during compilation:

import 'my_file.template.dart' as ng;

@GenerateInjector(const [
  const Provider(A, useClass: APrime),
])
// The generated factory is your method's name, suffixed with `$Injector`.
final InjectorFactory example = example$Injector;

Constructors

GenerateInjector(List<Object> _providersOrModules)
const
GenerateInjector.fromModules(List<Module> modules)
Generate an Injector from Modules instead of untyped lists.
const
factory

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
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
Returns a string representation of this object.
inherited

Operators

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