action_cable_stream 0.0.3


ActionCable in Dart using streams #

ActionCable is the default realtime websocket framework and protocol in Rails.

This is a dart port of the client and protocol implementation, which is available in web, dartVM and flutter.

This library is directly inspired by

Import #

  action_cable_stream: ^0.0.3

Usage #

  import 'dart:convert';
  import 'package:flutter/material.dart';

  import 'package:action_cable_stream/action_cable_stream.dart';
  import 'package:action_cable_stream/action_cable_stream_states.dart';

  class _MyHomePageState extends State<MyHomePage> {
    final String _channel = 'MyChannel';
    final String _action_cable_url = 'wss://';
    ActionCable _cable;

    void initState() {
      _cable = ActionCable.Stream(_action_cable_url); {
        if (value is ActionCableConnected) {
          _cable.subscribeToChannel(_channel, channelParams: {'id': 10});
        } else if (value is ActionCableSubscriptionConfirmed) {
          _cable.performAction(_channel, 'send_message',
              channelParams: {'id': 10}, actionParams: {'body': 'hello world'});
        } else if (value is ActionCableMessage) {
          print('ActionCableMessage ${jsonEncode(value.message)}');

    void dispose() {

    Widget build(BuildContext context) {
      return new Scaffold(
          appBar: new AppBar(
            title: new Text("Action Cable Stream example"),
          body: StreamBuilder(
            initialData: ActionCableInitial(),
            builder: (context, AsyncSnapshot<ActionCableDataState> snapshot) {
              return Center(child: buildBody(snapshot));

  Widget buildBody(AsyncSnapshot<ActionCableDataState> snapshot) {
    final state =;

    if (state is ActionCableInitial ||
        state is ActionCableConnectionLoading ||
        state is ActionCableSubscribeLoading) {
      return Text('Loading...');
    } else if (state is ActionCableError) {
      return Text('Error... ${state.message}');
    } else if (state is ActionCableSubscriptionConfirmed) {
      return Text('Subscription confirmed');
    } else if (state is ActionCableSubscriptionRejected) {
      return Text('Subscription rejected');
    } else if (state is ActionCableMessage) {
      return Text('Message received ${jsonEncode(state.message)}');
    } else if (state is ActionCableDisconnected) {
      return Text('Disconnected');
    } else {
      return Text('Something went wrong');

ActionCable protocol #

Anycable has a great doc on that topic.


  • First release


example #

A new Flutter project.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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

  action_cable_stream: ^0.0.3

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:action_cable_stream/action_cable_stream.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 11, 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 issues and suggestions

Document public APIs. (-1 points)

41 out of 41 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
rxdart >=0.20.0 <1.0.0 0.23.1
web_socket_channel ^1.1.0 1.1.0
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
stream_channel 2.0.0
typed_data 1.1.6