phoenix_wings 0.2.1

Build Status


phoenix_wings.dart #

A Phoenix Channel implementation for Dart

Attempts to feature match the Javascript implementation found at phoenix.js

Usage #

API Documentation

Much of the library is the same whether your code is running in the VM/Flutter or in a browser. Due to differences between the two platforms, the connection setup differs slightly.

Import & Connection (VM/Flutter)

import 'package:phoenix_wings/phoenix_wings.dart';

final socket = new PhoenixSocket("ws://localhost:4000/websocket/socket");

// equivalent to passing connectionProvider: PhoenixIoConnection.provider

Import & Connection (HTML)

import 'package:phoenix_wings/html.dart';

final socket = new PhoenixSocket("ws://localhost:4000/websocket/socket", connectionProvider: PhoenixHtmlConnection.provider);

Common Usage #

await socket.connect();

final chatChannel ="room:chat", {"id": "myId"});

chatChannel.on("user_entered", PhoenixMessageCallback (Map payload, String _ref, String, _joinRef) {


Testing #

Most of the tests are run on the VM. However, the PhoenixHtmlConnection tests must run in a browser.

By default tests will run on VM, Chrome and Firefox. This is set in dart_test.yaml

Tests are run via pub run test


  • Fix a bug where items were still added to StreamSink despite the connection being terminated


  • Fix a bug with socket options params vsn value being overridden
  • Remove dependency on Flutter
  • Move to TravisCI
  • Upgrade dependencies
  • Add the PhoenixPresence service which is a port of the Phoenix JavaScript client




example #

A super simple chat interface

Getting Started #

Run alongside the Phoenix server provided here too.

Use this package as a library

1. Depend on it

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

  phoenix_wings: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:phoenix_wings/phoenix_wings.dart';
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 Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Fix lib/src/phoenix_socket.dart. (-5.84 points)

Analysis of lib/src/phoenix_socket.dart reported 12 hints, including:

line 14 col 49: Unnecessary new keyword.

line 32 col 35: Unnecessary new keyword.

line 39 col 21: Use = to separate a named parameter from its default value.

line 40 col 25: Use = to separate a named parameter from its default value.

line 55 col 17: Unnecessary new keyword.

Fix lib/src/phoenix_channel.dart. (-3.93 points)

Analysis of lib/src/phoenix_channel.dart reported 8 hints, including:

line 20 col 34: Avoid const keyword.

line 46 col 9: Unnecessary new keyword.

line 59 col 11: Unnecessary new keyword.

line 87 col 9: Unnecessary new keyword.

line 87 col 28: Unnecessary new keyword.

Fix lib/src/phoenix_push.dart. (-1.99 points)

Analysis of lib/src/phoenix_push.dart reported 4 hints:

line 28 col 23: Unnecessary new keyword.

line 67 col 25: Unnecessary new keyword.

line 82 col 20: Unnecessary new keyword.

line 82 col 30: Unnecessary new keyword.

Fix additional 5 files with analysis or formatting issues. (-3.49 points)

Additional issues in the following files:

  • lib/src/phoenix_io_connection.dart (3 hints)
  • lib/src/phoenix_html_connection.dart (2 hints)
  • lib/src/phoenix_message.dart (1 hint)
  • lib/src/phoenix_presence.dart (1 hint)
  • lib/src/phoenix_socket_options.dart (Run dartfmt to format lib/src/phoenix_socket_options.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
Dev dependencies
dartdoc 0.28.3+2
intl ^0.15.6
mockito ^3.0.0
stream_channel 2.0.0
test 1.6.2