existsAtMostOnce method
Asserts that at most one widget of type W
exists.
This matcher is useful for scenarios where either one or no widget
of type W
should be present.
Example usage:
spot<ElevatedButton>().existsAtMostOnce();
See also:
- doesNotExist asserts that no widgets of type
W
exist. - existsOnce asserts that exactly one widget of type
W
exists. - existsExactlyNTimes asserts that exactly
n
widgets of typeW
exist. - existsAtLeastOnce asserts that at least one widget of type
W
exists. - existsAtLeastNTimes asserts that at least
n
widgets of typeW
exist. - existsAtMostNTimes asserts that at most
n
widgets of typeW
exist.
Implementation
WidgetMatcher<W> existsAtMostOnce() {
final atMostOne = copyWith(quantityConstraint: QuantityConstraint.single);
return snapshot(atMostOne).single;
}