Reputation: 98
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 ?
Upvotes: 1
Views: 559
Reputation: 21
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);
}
Upvotes: 0