SocketIO Flutter Plugin
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
android First commit Sep 14, 2018
example
ios
lib
CHANGELOG.md
LICENSE
README.md
pubspec.lock
pubspec.yaml First commit Sep 14, 2018
socket_flutter_plugin.iml
socket_flutter_plugin_android.iml First commit Sep 14, 2018

README.md

socket_flutter_plugin

Support both Android and iOS

Demo

Website

Android

iOS

Example

import 'package:socket_flutter_plugin/socket_flutter_plugin.dart';
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    try {
      SocketFlutterPlugin myIO = new SocketFlutterPlugin();
      myIO.socket("http://10.2.2.22:9006");
      myIO.connect();
      String jsonData =
              '{"content":"test"}';
      myIO.emit("chat",jsonData);
      myIO.on("chat",(data){
        debugPrint(data.toString());
      });
    } on PlatformException {

      _platformVersion = 'Failed to get platform version.';
    }
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('Test socketio'),
        ),
      ),
    );
  }
}