Future<bool> contains(Object needle)

Checks whether needle occurs in the elements provided by this stream.

Completes the Future when the answer is known. If this stream reports an error, the Future will report that error.


Future<bool> contains(Object needle) {
  _Future<bool> future = new _Future<bool>();
  StreamSubscription subscription;
  subscription = this.listen(
      (T element) {
          () => (element == needle),
          (bool isMatch) {
            if (isMatch) {
              _cancelAndValue(subscription, future, true);
          _cancelAndErrorClosure(subscription, future)
      onError: future._completeError,
      onDone: () {
      cancelOnError: true);
  return future;