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 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;
Annotations
  • @Target({TargetKind.topLevelVariable})

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.
no setterinherited
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