GeneratorForAnnotation<T> class

Extend this type to create a Generator that invokes generateForAnnotatedElement for every element in the source file annotated with T.

When all annotated elements have been processed, the results will be combined into a single output with duplicate items collapsed.

For example, this will allow code generated for all elements which are annotated with @Deprecated:

class DeprecatedGenerator extends GeneratorForAnnotation<Deprecated> {
  @override
  Future<String> generateForAnnotatedElement(
      Element element,
      ConstantReader annotation,
      BuildStep buildStep) async {
    // Return a string representing the code to emit.
  }
}
Inheritance

Constructors

GeneratorForAnnotation()
const

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
typeChecker TypeChecker
read-only

Methods

generate(LibraryReader library, BuildStep buildStep) FutureOr<String>
Generates Dart code for an input Dart library. [...]
override
generateForAnnotatedElement(Element element, ConstantReader annotation, BuildStep buildStep) → dynamic
Implement to return source code to generate for element. [...]
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