byElementPredicate method

Finder byElementPredicate(
  1. ElementPredicate predicate, {
  2. String? description,
})

Finds components using an element predicate.

Sample code

expect(find.byElementPredicate(
  // finds elements of type SingleChildElement, including
  // those that are actually subclasses of that type.
  // (contrast with byElementType, which only returns exact matches)
  (Element element) => element is SingleChildElement,
  description: '$SingleChildElement element',
), findsOneComponent);

If description is provided, then this uses it as the description of the Finder and appears, for example, in the error message when the finder fails to locate the desired component. Otherwise, the description prints the signature of the predicate function.

Implementation

Finder byElementPredicate(ElementPredicate predicate, {String? description}) {
  return _ElementPredicateFinder(predicate, description: description);
}