1

How to connect my flutter app to flask_socketIO python ? In flutter i am making a chat APP whose backend to fetch the users is in flask bakcend. So how should i connect both of them ?

Atul Dubey
  • 63
  • 1
  • 5

1 Answers1

0

you can use this package flutter_socket_io

Initialize your socket io server

SocketIO socketIO = SocketIOManager()
                      .createSocketIO("http://127.0.0.1:3000", 
                      "/chat", 
                      query: "userId=21031", 
                      socketStatusCallback: _socketStatus);  

Initialization and subscription to your socket backend

socketIO.init(); 
socketIO.subscribe("socket_info", _onSocketInfo); 
socketIO.connect(); 

Add a callback function to listen for any new information coming in and do whatever u want with the data

_socketStatus(dynamic data) { 
    //do whatever
    print("Socket status: " + data); 
}
Yue Hern
  • 11
  • 1
  • 3
  • java.lang.classnotfoundexception com.mediatek.cta.ctahttp Yes Bro I have connected but Now i am getting this error in my debug console – Atul Dubey Jun 24 '20 at 14:06
  • please try to look at this thread to fix (https://stackoverflow.com/questions/54621628/android-jdbc-connection-results-in-ctahttp-exception) – Yue Hern Jun 25 '20 at 15:02