socket_io 0.8.2

  • Installing
  • Versions
  • 82

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.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub 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.2 Jul 20, 2018 Go to the documentation of socket_io 0.8.2 Download socket_io 0.8.2 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
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.11.8


Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 Because socket_io depends on uuid >=0.0.7 <1.0.3 which requires SDK version <2.0.0, version solving failed.

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.


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

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 of the 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.

Format lib/socket_io.dart.

Run dartfmt to format lib/socket_io.dart.

Format lib/src/adapter/adapter.dart.

Run dartfmt to format lib/src/adapter/adapter.dart.

Use analysis_options.yaml.

Rename old .analysis_options file to analysis_options.yaml.

Read more about the setup of analysis-options.yaml.

Fix additional 18 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/client.dart (Run dartfmt to format lib/src/client.dart.)
  • lib/src/engine/connect.dart (Run dartfmt to format lib/src/engine/connect.dart.)
  • lib/src/engine/engine.dart (Run dartfmt to format lib/src/engine/engine.dart.)
  • lib/src/engine/parser/parser.dart (Run dartfmt to format lib/src/engine/parser/parser.dart.)
  • lib/src/engine/parser/wtf8.dart (Run dartfmt to format lib/src/engine/parser/wtf8.dart.)
  • lib/src/engine/server.dart (Run dartfmt to format lib/src/engine/server.dart.)
  • lib/src/engine/socket.dart (Run dartfmt to format lib/src/engine/socket.dart.)
  • lib/src/engine/transport/jsonp_transport.dart (Run dartfmt to format lib/src/engine/transport/jsonp_transport.dart.)
  • lib/src/engine/transport/polling_transport.dart (Run dartfmt to format lib/src/engine/transport/polling_transport.dart.)
  • lib/src/engine/transport/transports.dart (Run dartfmt to format lib/src/engine/transport/transports.dart.)
  • lib/src/engine/transport/websocket_transport.dart (Run dartfmt to format lib/src/engine/transport/websocket_transport.dart.)
  • lib/src/engine/transport/xhr_transport.dart (Run dartfmt to format lib/src/engine/transport/xhr_transport.dart.)
  • lib/src/namespace.dart (Run dartfmt to format lib/src/namespace.dart.)
  • lib/src/parser/binary.dart (Run dartfmt to format lib/src/parser/binary.dart.)
  • lib/src/parser/parser.dart (Run dartfmt to format lib/src/parser/parser.dart.)
  • lib/src/server.dart (Run dartfmt to format lib/src/server.dart.)
  • lib/src/socket.dart (Run dartfmt to format lib/src/socket.dart.)
  • lib/src/util/event_emitter.dart (Run dartfmt to format lib/src/util/event_emitter.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0