presentUnsubscribeFromStream method
void
presentUnsubscribeFromStream()
more stream methods
Implementation
void presentUnsubscribeFromStream() {
var data = intList; // some sample data
Stream stream = Stream.fromIterable(data); // create the stream
var subscription = stream.listen(null);
subscription.onData((value) {
print("listen: $value");
if (value == 2) subscription.cancel(); // cancel the subscription
});
subscription.onError((err) => print("error: $err"));
subscription.onDone(() => print("done"));
}