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,
) {
// Look for shrinkWrap: true arguments directly
context.addNamedExpression((NamedExpression node) {
if (node.name.label.name != 'shrinkWrap') return;
final Expression value = node.expression;
if (value is! BooleanLiteral || !value.value) return;
// Check if this shrinkWrap is on a scrollable widget
final AstNode? scrollableWidget = _findParentScrollable(node);
if (scrollableWidget == null) return;
// Skip if the scrollable has NeverScrollableScrollPhysics
// Check the siblings of shrinkWrap for physics argument
if (_hasNeverScrollablePhysicsInSiblings(node)) return;
// Check if that scrollable is inside another scrollable
if (_isInsideScrollable(scrollableWidget)) {
reporter.atNode(node);
}
});
}