existsAtLeastOnce method
Asserts that at least one widget of type W
exists.
This matcher is used when the expectation is to have one or more
widgets of type W
present in the widget tree.
Example usage:
spot<ElevatedButton>().existsAtLeastOnce();
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. - existsAtLeastNTimes asserts that at least
n
widgets of typeW
exist. - existsAtMostOnce asserts that at most one widget exists.
- existsAtMostNTimes asserts that at most
n
widgets of typeW
exist.
Implementation
MultiWidgetMatcher<W> existsAtLeastOnce() {
final atLeastOne =
copyWith(quantityConstraint: const QuantityConstraint.atLeast(1));
return snapshot(atLeastOne).multi;
}