existsAtMostOnce method

WidgetMatcher<W> existsAtMostOnce()

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:

Implementation

WidgetMatcher<W> existsAtMostOnce() {
  final atMostOne = copyWith(quantityConstraint: QuantityConstraint.single);
  return snapshot(atMostOne).single;
}