evaluate method

  1. @override
FutureOr<Evaluation> evaluate (WidgetTester tester)

Evaluate whether the current state of the tester conforms to the rule.


FutureOr<Evaluation> evaluate(WidgetTester tester) {
 final SemanticsNode root = tester.binding.pipelineOwner.semanticsOwner.rootSemanticsNode;
  Evaluation traverse(SemanticsNode node) {
    Evaluation result = const Evaluation.pass();
    node.visitChildren((SemanticsNode child) {
      result += traverse(child);
      return true;
    if (node.isMergedIntoParent || node.isInvisible || node.hasFlag(ui.SemanticsFlag.isHidden))
      return result;
    final SemanticsData data = node.getSemanticsData();
    // Skip node if it has no actions, or is marked as hidden.
    if (!data.hasAction(ui.SemanticsAction.longPress) && !data.hasAction(ui.SemanticsAction.tap))
      return result;
    if (data.label == null || data.label.isEmpty) {
      result += Evaluation.fail(
        '$node: expected tappable node to have semantic label, but none was found\n',
    return result;
  return traverse(root);