Checks whether test
accepts all elements provided by this stream.
Calls test
on each element of the stream. If the call returns false
, the returned future is completed with false
and processing stops.
If the stream ends without finding an element that test
rejects, the returned future is completed with true
.
If this stream contains an error, or if the call to test
throws, the returned future is completed with that error, and processing stops.
Future<bool> every(bool test(T element)) { _Future<bool> future = new _Future<bool>(); StreamSubscription subscription; subscription = this.listen( (T element) { _runUserCode(() => test(element), (bool isMatch) { if (!isMatch) { _cancelAndValue(subscription, future, false); } }, _cancelAndErrorClosure(subscription, future)); }, onError: future._completeError, onDone: () { future._complete(true); }, cancelOnError: true); return future; }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-async/Stream/every.html