drain<E> method
- [E? futureValue]
Discards all data on this stream, but signals when it is done or an error occurred.
When subscribing using drain, cancelOnError will be true. This means that the future will complete with the first error on this stream and then cancel the subscription.
If this stream emits an error, the returned future is completed with that error, and processing is stopped.
In case of a done
event the future completes with the given futureValue
.
The futureValue
must not be omitted if null
is not assignable to E
.
Implementation
Future<E> drain<E>([E? futureValue]) { if (futureValue == null) { futureValue = futureValue as E; } return listen(null, cancelOnError: true).asFuture<E>(futureValue); }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-async/Stream/drain.html