existsOnce method
Asserts that exactly one widget of type W
exists.
Example usage:
spot<ElevatedButton>().existsOnce();
See also:
- doesNotExist asserts that no widgets of type
W
exist. - 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. - existsAtMostOnce asserts that at most one widget exists.
- existsAtMostNTimes asserts that at most
n
widgets of typeW
exist.
Implementation
WidgetMatcher<W> existsOnce() {
final one =
copyWith(quantityConstraint: const QuantityConstraint.exactly(1));
return snapshot(one).single;
}