check method
Inspects nodes — a snapshot captured by SemanticsTreeWalker — and
returns any violations found.
Implementation
@override
List<A11yViolation> check(List<A11ySemanticsNodeInfo> nodes) {
final violations = <A11yViolation>[];
for (final node in nodes) {
final siblings = node.childrenInTraversalOrder
.where((child) => child.isInteractive && !child.isHidden)
.toList(growable: false);
if (siblings.length < 2) continue;
final readingOrder = [...siblings]..sort(_byReadingOrder);
if (_sameOrder(siblings, readingOrder)) continue;
violations.add(
A11yViolation(
ruleId: id,
severity: A11ySeverity.warning,
bounds: node.rect,
message:
'Focus order among ${siblings.length} sibling widgets does '
'not match their visual layout — a screen reader or switch '
'control would move through them out of visual order.',
suggestedFix:
'Reorder the widgets in the build method to match the visual '
'layout, or set an explicit Semantics(sortKey: ...) to '
'control traversal order directly.',
),
);
}
return violations;
}