socket_io 0.8.1

  • Installing
  • Versions
  • 77

Port of awesome JavaScript Node.js library - v2.0.1 - in Dart


import 'package:socket_io/socket_io.dart';

main() {
    var io = new Server();
    var nsp = io.of('/some');
    nsp.on('connection', (Socket client) {
      print('connection /some');
      client.on('msg', (data) {
        print('data from /some => $data');
        client.emit('fromServer', "ok 2");
      io.on('connection', (Socket client) {
        print('connection default namespace');
        client.on('msg', (data) {
          print('data from default => $data');
          client.emit('fromServer', "ok");

// JS client
var socket = io('http://localhost:3000');
socket.on('connect', function(){console.log('connect')});
socket.on('event', function(data){console.log(data)});
socket.on('disconnect', function(){console.log('disconnect')});
socket.on('fromServer', function(e){console.log(e)});

// Dart client
import 'package:socket_io_client/socket_io_client.dart' as IO;

IO.Socket socket ='http://localhost:3000');
socket.on('connect', (_) {
  socket.emit('msg', 'test');
socket.on('event', (data) => print(data));
socket.on('disconnect', (_) => print('disconnect'));
socket.on('fromServer', (_) => print(_));

Multiplexing support

Same as Socket.IO, this project allows you to create several Namespaces, which will act as separate communication channels but will share the same underlying connection.

Room support

Within each Namespace, you can define arbitrary channels, called Rooms, that sockets can join and leave. You can then broadcast to any given room, reaching every socket that has joined it.

Transports support

Refers to

  • polling: XHR / JSONP polling transport.
  • websocket: WebSocket transport.

Adapters support

Notes to Contributors


If you'd like to contribute back to the core, you can fork this repository and send us a pull request, when it is ready.

If you are new to Git or GitHub, please read this guide first.

Who Uses

  • Quire - a simple, collaborative, multi-level task management tool.
  • KEIKAI - a web spreadsheet for Big Data. Dart Client

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  socket_io: "^0.8.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:socket_io/socket_io.dart';
Version Uploaded Documentation Archive
0.8.1 Jun 4, 2018 Go to the documentation of socket_io 0.8.1 Download socket_io 0.8.1 archive
0.8.0 Apr 9, 2018 Go to the documentation of socket_io 0.8.0 Download socket_io 0.8.0 archive


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
67 / 100
Code health derived from static analysis. [more]
92 / 100
Reflects how tidy and up-to-date the package is. [more]
77 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Primary library: package:socket_io/socket_io.dart with components: io.


  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 4 errors 66 hints.

    Strong-mode analysis of lib/src/engine/parser/parser.dart failed with the following error:

    line: 337 col: 41
    The function expression type '(dynamic, List<dynamic>) → dynamic' isn't of type '(dynamic, dynamic) → dynamic'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).

    Strong-mode analysis of lib/src/engine/transport/polling_transport.dart failed with the following error:

    line: 206 col: 40
    The argument type '(Map<dynamic, dynamic>, [dynamic, dynamic]) → bool' can't be assigned to the parameter type '(dynamic, [dynamic, dynamic]) → dynamic'.

    Similar analysis of the following files failed:

    • lib/src/util/event_emitter.dart (error)
    • lib/socket_io.dart (hint)
    • lib/src/adapter/adapter.dart (hint)
    • lib/src/client.dart (hint)
    • lib/src/engine/connect.dart (hint)
    • lib/src/engine/engine.dart (hint)
    • lib/src/engine/parser/wtf8.dart (hint)
    • lib/src/engine/server.dart (hint)
    • lib/src/engine/socket.dart (hint)
    • lib/src/engine/transport/jsonp_transport.dart (hint)
    • lib/src/engine/transport/transports.dart (hint)
    • lib/src/engine/transport/websocket_transport.dart (hint)
    • lib/src/engine/transport/xhr_transport.dart (hint)
    • lib/src/namespace.dart (hint)
    • lib/src/parser/binary.dart (hint)
    • lib/src/parser/parser.dart (hint)
    • lib/src/server.dart (hint)
    • lib/src/socket.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use socket_io.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0
logging >=0.11.3+1 <0.12.0 0.11.3+1
stream >=1.6.6+1 <2.0.0 1.7.0+2
uuid >=0.5.3 <0.6.0 0.5.3 1.0.0
Transitive dependencies
args 1.4.3
async 2.0.7
charcode 1.1.1
collection 1.14.10
convert 2.0.1
crypto 2.0.5
http 0.11.3+16
http_parser 3.1.2
mime 0.9.6+1
path 1.6.1
rikulo_commons 2.3.8+1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test >=0.12.0 <0.13.0
unittest any