Future<bool> isEmpty

Reports whether this stream contains any elements.

Stops listening to the stream after the first element has been received.

Internally the method cancels its subscription after the first element. This means that single-subscription (non-broadcast) streams are closed and cannot be reused after a call to this getter.


Future<bool> get isEmpty {
  _Future<bool> future = new _Future<bool>();
  StreamSubscription subscription;
  subscription = this.listen(
      (_) {
        _cancelAndValue(subscription, future, false);
      onError: future._completeError,
      onDone: () {
      cancelOnError: true);
  return future;