I know I have to cancel Stream
Subscriptions when I no longer want to receive any events.
Do I have to this even after I receive a \'Done\' event? Or do I get memor
I found in my case that if I have code like this:
Stream readHackerNews(String path) {
StreamController controller = StreamController();
......
return controller.stream;
}
I see a warning message "Close instance of 'dart.core.Sink'." in the Visual Studio Code. In order to fix this warning I added
controller.close()
to the event handler for the OnCancel event, see below:
Stream readHackerNews(String path) {
StreamController controller = StreamController();
//TODO: your code here
controller.onCancel = () {
controller.close();
};
return controller.stream;
}
Hope this helps!