i am trying to implement socket.io with my flutter app, currently flutter is supporting WebSocket but i have found a way for socket.io in package "dart.io" but i am unable to understand how to emit a message on a specific event. Any suggestions would be helpful :)
3 Answers
I have ported socket.io in dart code since 2017, and it can work with flutter as well in the same codebase - socket.io-client-dart and socket.io-dart.
Comments
Using this flutter_socket_io package, I managed to connect to my local Socket IO server.
SocketIO socket = SocketIOManager().createSocketIO("http://localhost:3000", "/");
socket.init();
socket.connect();
Maybe you could share your implementation on both client and server side to debug further.
Comments
I think you looking for this flutter_socket_io
4 Comments
Muhammad Faizan
check my last comment to Günter Zöchbauer. "i have tested this plugin but it is unable to connect, My native android side is working fine. createSocketIO() has 4 parameters, i have input the domain, have no namespace so i tried empty string and null but no success in sending the message. Logcat shows the isConnected:false. Need help on this one"
Abdussalam Ashuaebi
use "/" in namespace parameter as default namespace in socket io
Muhammad Faizan
namespace as you said but still the socket status is interchanging from "reconnecting" to "disconnect" socketIO = SocketIOManager().createSocketIO(SOCKET_URL, "/", socketStatusCallback: _socketStatus); socketIO.init(); socketIO.connect();
Muhammad Faizan
i am pretty sure thats not the issue, internet permission is also in the android manifest.
IO.Socket socket = IO.io(SOCKET_URL); socket.connect();then i get an error of