mayEmit function

StreamMatcher mayEmit (dynamic 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(matcher) {
  var streamMatcher = emits(matcher);
  return StreamMatcher((queue) async {
    await queue.withTransaction(
        (copy) async => (await streamMatcher.matchQueue(copy)) == null);
    return null;
  }, "maybe ${streamMatcher.description}");
}