run method
void
run(
- CustomLintResolver resolver,
- ErrorReporter reporter,
- CustomLintContext context
Emits lints for a given file.
run will only be invoked with files respecting filesToAnalyze
Implementation
@override
void run(
CustomLintResolver resolver,
ErrorReporter reporter,
CustomLintContext context,
) {
context.registry.addInstanceCreationExpression((node) {
final type = node.constructorName.type.type;
if (type == null) return;
final String typeName = type.toString();
// Check for ListView.builder, GridView.builder, etc.
if (_isListViewBuilder(typeName, node)) {
// Find the itemBuilder parameter
for (final argument in node.argumentList.arguments) {
if (argument is NamedExpression &&
argument.name.label.name == 'itemBuilder') {
_checkItemBuilder(argument.expression, reporter);
}
}
}
});
}