I have the following stream subscription
Stream<Uint8List> stream = await USBSerialSingleton.instance.inputStream;
usbStream = stream.listen(onDataReceivedFromUSBSerial);
The inputStream
is a broadcast stream exposed like this.
Future<Stream<Uint8List>> get inputStream async {
final UsbPort port = await this.port;
return port.inputStream.asBroadcastStream();
}
I would like to stop listening to the stream, so I am calling
usbStream.cancel();
But I keep receiving messages on my onDataReceivedFromUSBSerial
method. I keep getting messages on the onDataReceivedFromUSBSerial
even if I close the dialogue that all this is implemented on.
Question: How do I stop listening to my usbStream
?