generateForAnnotatedElement method
String
generateForAnnotatedElement(
- Element element,
- ConstantReader annotation,
- BuildStep buildStep
Generates Dart source for a class marked with the @module()
annotation.
Throws InvalidGenerationSourceError
if used on anything except a class.
See file-level docs for usage and generated output example.
Implementation
@override
String generateForAnnotatedElement(
Element element,
ConstantReader annotation,
BuildStep buildStep,
) {
if (element is! ClassElement) {
throw InvalidGenerationSourceError(
'@module() can only be applied to classes.',
element: element,
);
}
final classElement = element;
final generatedClass = GeneratedClass.fromClassElement(classElement);
return generatedClass.generate();
}