adhara_socket_io 0.1.7 adhara_socket_io: ^0.1.7 copied to clipboard
Websocket by socket.io for flutter by adhara, supports both iOS and Android
adhara_socket_io #
socket.io for flutter by adhara
supports both Android and iOS
Usage:
See example/lib/main.dart
for better example
SocketIO socket = await SocketIOManager().createInstance('http://192.168.1.2:7000/'); //TODO change the port accordingly
socket.onConnect((data){
print("connected...");
print(data);
socket.emit("message", ["Hello world!"]);
});
socket.on("news", (data){ //sample event
print("news");
print(data);
});
socket.connect();
Running example: #
-
Open
example/ios
in XCode orexample/android
in android studio. Build the code once (cd example
&flutter build apk
|flutter build ios --no-codesign
) -
cd
example/socket.io.server
1 run
npm i
2 run
npm start
-
open
example/lib/main.dart
and edit the URI in #7 to point to your hosted/local socket server instances as mentioned step 2 -
run Android/iOS app
Feel free to checkout our Adhara package