whereWidgetProp<T> method
Creates a filter for the widgets of the discovered elements which is applied when the WidgetSelector is snapshotted.
Example usage:
spotSingle<Checkbox>()
.whereWidgetProp(
prop: widgetProp('isChecked', (widget) => widget.value),
match: (value) => value == true,
).existsOnce();
Implementation
@useResult
WidgetSelector<W> whereWidgetProp<T>(
NamedWidgetProp<W, T> prop,
bool Function(T value) match,
) {
return self!.addStage(
PredicateFilter(
predicate: (Element element) {
final widget = self!.mapElementToWidget(element);
final value = prop.get(widget);
return match(value);
},
description: prop.name,
),
);
}