generateForAnnotatedElement method
dynamic
generateForAnnotatedElement(
- BuildStep buildStep,
- Element element,
- ElementAnnotation annotation
override
Generates code for a single annotated element.
This is called for each element in the library that has the annotation this generator is targeting.
@param buildStep The build step providing context for generation @param element The annotated element @param annotation The annotation instance on the element @return Generated code as a string, or null if nothing to generate
Implementation
@override
dynamic generateForAnnotatedElement(
BuildStep buildStep,
Element element,
ElementAnnotation annotation,
) {
if (element is! ClassElement) {
throw InvalidGenerationSourceError(
'Expected a class element but found ${element.runtimeType}.',
element: element,
);
}
return generateForClass(buildStep, element, annotation);
}