websockets 0.2.1+1

  • README.md
  • Installing
  • Versions
  • 63


A platform-independent WebSocket library using the Dart async API.

This library defines a WebSocket interface very much like the one in dart:io that can be used when writing platform-independent packages like API-wrappers.


The documentation for this library can be found on DartDocs.


Creating and using WebSockets with this library is easy, it works entirely the same as how the dart:io.WebSocket class works:

import "dart:io";
import "package:websockets/websockets.dart";

main() async {
  WebSocket ws = await WebSocket.connect("wss://echo.websocket.org");

When developing platform-independent packages

Everything stays the same. The websockets import does not import dart:io or dart:html, so your code will run on both platforms. One thing to remember is that the user of your library has to make an explicit import of either of dart:io or dart:html.



  • Environment import is no longer required in the browser.


  • Completely reworked the mirrors code to make WebSocket.connect work for dart:html
  • It is now also easier to add new environments that WebSocket.connect can work with
  • BrowserWebSocket class is removed
  • WebSocketConnector is removed


  • Added url getter


  • Initial version

1. Depend on it

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

  websockets: "^0.2.1+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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:websockets/websockets.dart';
Version Uploaded Documentation Archive
0.2.1+1 May 12, 2016 Go to the documentation of websockets 0.2.1+1 Download websockets 0.2.1+1 archive
0.2.1 Jan 19, 2016 Go to the documentation of websockets 0.2.1 Download websockets 0.2.1 archive
0.2.0+2 Jan 9, 2016 Go to the documentation of websockets 0.2.0+2 Download websockets 0.2.0+2 archive
0.2.0+1 Jan 9, 2016 Go to the documentation of websockets 0.2.0+1 Download websockets 0.2.0+1 archive
0.2.0 Jan 9, 2016 Go to the documentation of websockets 0.2.0 Download websockets 0.2.0 archive
0.1.1 Jun 17, 2015 Go to the documentation of websockets 0.1.1 Download websockets 0.1.1 archive
0.1.0 Jun 16, 2015 Go to the documentation of websockets 0.1.0 Download websockets 0.1.0 archive
0.0.0 Jun 16, 2015 Go to the documentation of websockets 0.0.0 Download websockets 0.0.0 archive


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

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6


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


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:websockets/websockets.dart.


  • 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 websockets.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run dartfmt to format lib/src/environments/html/html_websocket_impl.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.12.0 <2.0.0
reflectable ^0.5.4 0.5.4 2.0.0
Transitive dependencies
analyzer 0.27.6 0.31.1
args 0.13.7 1.4.2
async 2.0.6
barback 0.15.2+15
charcode 1.1.1
cli_util 0.0.1+2 0.1.2+1
code_transformers 0.4.2+3 0.5.1+4
collection 1.14.9
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
dart_style 0.2.11+1 1.0.10
glob 1.1.5
html 0.13.3
isolate 0.2.3 2.0.0
logging 0.11.3+1
package_config 1.0.3
path 1.5.1
plugin 0.2.0+2
pool 1.3.4
source_maps 0.10.4
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
when 0.2.0
which 0.1.3
yaml 2.1.13
Dev dependencies
test any