byWidgetPredicate method
- WidgetPredicate predicate, {
- String? description,
- bool skipOffstage = true,
Finds widgets using a widget predicate
.
Sample code
expect(find.byWidgetPredicate(
(Widget widget) => widget is Tooltip && widget.message == 'Back',
description: 'with tooltip "Back"',
), findsOneWidget);
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 widget. Otherwise, the description prints the
signature of the predicate function.
If the skipOffstage
argument is true (the default), then this skips
nodes that are Offstage or that are from inactive Routes.
Implementation
Finder byWidgetPredicate(WidgetPredicate predicate, { String? description, bool skipOffstage = true }) {
return _WidgetPredicateWidgetFinder(predicate, description: description, skipOffstage: skipOffstage);
}