Reputation: 247
I am using a Socket for a project. I connected it to a listener using the following code:
widget.secureSocket.listen((message) => onMessageReceived(String.fromCharCodes(message)));
How can I remove/disconnect onMessageReceived(...) from the socket?
Thank you in advance
Paul
Upvotes: 0
Views: 2322
Reputation: 886
listen()
method returns a StreamSubscription
, which you can cancel later.
var sub = widget.secureSocket.listen(...);
To cancel it:
sub.cancel();
Upvotes: 2