check method

  1. @override
List<A11yViolation> check(
  1. List<A11yElementInfo> elements
)
override

Inspects elements — a snapshot of the tree captured by the ElementTreeWalker — and returns any violations found.

Implementation

@override
List<A11yViolation> check(List<A11yElementInfo> elements) {
  final violations = <A11yViolation>[];

  for (final info in elements) {
    if (!interactiveTypes.contains(info.widgetType)) continue;

    final bounds = info.bounds;
    if (bounds == null) continue;
    if (bounds.width >= minimumSize && bounds.height >= minimumSize) {
      continue;
    }

    violations.add(
      A11yViolation(
        ruleId: id,
        severity: A11ySeverity.warning,
        widgetType: info.widgetType.toString(),
        bounds: bounds,
        message:
            '${info.widgetType} tap target is '
            '${bounds.width.toStringAsFixed(0)}x'
            '${bounds.height.toStringAsFixed(0)}, below the '
            '${minimumSize.toStringAsFixed(0)}x'
            '${minimumSize.toStringAsFixed(0)} minimum.',
        suggestedFix:
            'Wrap in a SizedBox(width: $minimumSize, height: $minimumSize) '
            'or add padding so the tappable area meets the minimum size.',
      ),
    );
  }

  return violations;
}