whereWidget method
Creates a filter for the widgets of the discovered elements which is applied when the WidgetSelector is snapshotted.
The description
is required to make error messages understandable
Example usage:
spotSingle<Checkbox>()
.whereWidget(
(widget) => widget.value == true,
description: 'isChecked',
).existsOnce();
Implementation
@useResult
WidgetSelector<W> whereWidget(
bool Function(W widget) predicate, {
required String description,
}) {
return self.addStage(
PredicateFilter(
predicate: (Element element) {
final widget = self.mapElementToWidget(element);
return predicate(widget);
},
description: description,
),
);
}