mayEmit function

StreamMatcher mayEmit(
  1. Object? matcher
)

Returns a StreamMatcher that allows (but doesn't require) matcher to match the stream.

This matcher always succeeds; if matcher doesn't match, this just consumes no events.

Implementation

StreamMatcher mayEmit(Object? matcher) {
  var streamMatcher = emits(matcher);
  return StreamMatcher((queue) async {
    await queue.withTransaction(
        (copy) async => (await streamMatcher.matchQueue(copy)) == null);
    return null;
  }, 'maybe ${streamMatcher.description}');
}