socket.io-client-dart
socket.io-client-dart copied to clipboard
how to check and add events dynamically
I want to check if event already exists and add the event only if it is missing....
how to do it...??
I am using getx controller attached to the page to connect and destroy socket io... but however after multiple close and open of the same page, seems like same event triggered multiple time...
I am destroying socket at onClose event but still seems like it remembers all the events and when you estatblish connection it calls same event multiple times...
@override
void onClose() {
if (socket.connected) {
socket.disconnect();
socket.destroy();
}
super.onClose();
}
seems like issue is simlar to #230
after some research in google I found one workaround solution which seems like working...
you need to add clearListeners()
call... though you are destroying socket still it remembers listeners....
@override
void onClose() {
if (socket.connected) {
socket.clearListeners();
socket.disconnect();
socket.destroy();
}
super.onClose();
}