run method

  1. @override
void run(
  1. CustomLintResolver resolver,
  2. ErrorReporter reporter,
  3. 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.addMethodInvocation((node) {
    if (!_isAppMethod(node, 'column') && !_isAppMethod(node, 'row')) {
      return;
    }

    final childrenArg = _findNamedArgument(node, 'children');
    if (childrenArg == null) return;

    // Check if it's an empty list
    if (childrenArg is ListLiteral && childrenArg.elements.isEmpty) {
      reporter.atNode(childrenArg, code);
    }
  });
}