runWithReporter method
Override this method to implement your lint rule.
Use context to register callbacks for AST node types:
context.addMethodInvocation((node) {
if (condition) {
reporter.atNode(node);
}
});
Implementation
@override
void runWithReporter(
SaropaDiagnosticReporter reporter,
SaropaContext context,
) {
context.addInstanceCreationExpression((InstanceCreationExpression node) {
final typeName = node.constructorName.type.name.lexeme;
if (typeName != 'DropdownButtonFormField') return;
for (final arg in node.argumentList.arguments) {
if (arg is NamedExpression && arg.name.label.name == 'value') {
reporter.atNode(arg.name);
return;
}
}
});
}