websockets 0.2.1+1

  • README.md
  • Installing
  • Versions
  • 62


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

Use this package as a library

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

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: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
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 Jul 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7


Detected platforms: web, other

Primary library: package:websockets/websockets.dart with components: mirrors.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Package is too old.

The package was released more than two years ago.

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

Format lib/env/io.dart.

Run dartfmt to format lib/env/io.dart.

Format lib/src/environments/html/html_websocket_impl.dart.

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.1
Transitive dependencies
analyzer 0.27.6 0.32.3
args 0.13.7 1.4.4
async 2.0.8
barback 0.15.2+16
charcode 1.1.2
cli_util 0.0.1+2 0.1.3+2
code_transformers 0.4.2+3 0.5.1+5
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.4 0.14.4+1
dart_style 0.2.11+1 1.1.3
glob 1.1.7
html 0.13.3+2
isolate 0.2.3 2.0.2
logging 0.11.3+2
package_config 1.0.5
path 1.6.2
plugin 0.2.0+3
pool 1.3.5
source_maps 0.10.7
source_span 1.4.1
stack_trace 1.9.3
string_scanner 1.0.3
typed_data 1.1.6
utf 0.9.0+5
watcher 0.9.7+10
when 0.2.0
which 0.1.3
yaml 2.1.15
Dev dependencies
test any