websockets 0.2.1+1

  • README.md
  • Installing
  • Versions
  • 23


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.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

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

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.12.0 <2.0.0