byPredicate method

SemanticsFinder byPredicate(
  1. SemanticsNodePredicate predicate, {
  2. DescribeMatchCallback? describeMatch,
  3. FlutterView? view,
})

Finds any SemanticsNodes matching the given predicate.

If describeMatch is provided, it will be used to describe the FinderBase and FinderResults. The description returned should be a brief English phrase describing a matching candidate with the proper plural form. As an example for a string finder that is looking for strings starting with "hello":

String describeMatch(Plurality plurality) {
  return switch (plurality) {
    Plurality.zero || Plurality.many => 'strings starting with "hello"',
    Plurality.one => 'string starting with "hello"',
  };
}

The view provided will be used to determine the semantics tree where the search will be evaluated. If not provided, the search will be evaluated against the semantics tree of WidgetTester.view.

Implementation

SemanticsFinder byPredicate(
  SemanticsNodePredicate predicate, {
  DescribeMatchCallback? describeMatch,
  FlutterView? view,
}) {
  return _PredicateSemanticsFinder(
    predicate,
    describeMatch,
    view,
  );
}