Search packages, repositories and app categories

Package detailsv1.3.0

action_cable

ActionCable client port in dart, available in web, dartVM and flutter.

AndroidiOSmacOSWindowsLinux
30-day downloads
1.5K
Likes
22
Pub points
135

Install package

flutter pub add action_cable

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

ActionCable is a Dart client implementation of Rails' ActionCable, enabling real-time bidirectional communication over WebSocket in Flutter and Dart applications. It supports web, DartVM, and mobile platforms including Android, iOS, macOS, Windows, and Linux. The package allows seamless integration with ActionCable servers for features like live updates, chat systems, and notifications. It provides a clean API to subscribe to channels, receive messages, and manage connections with built-in reconnection logic. Ideal for apps requiring real-time data synchronization.

Use cases

  • Real-time chat applications
  • Live dashboard updates
  • Notification systems
  • Collaborative editing tools
  • Streaming data feeds

Key features

  • WebSocket-based real-time communication
  • Cross-platform support (web, mobile, desktop)
  • Channel subscription management
  • Automatic reconnection
  • Simple event-driven API

Suitable for

  • Flutter apps needing real-time features
  • Dart projects using Rails backend
  • Developers building live interactive UIs
  • Apps requiring low-latency updates
  • Teams using ActionCable on the server side

Considerations

  • Requires a compatible ActionCable server
  • Network reliability affects performance
  • Limited documentation compared to mature alternatives
  • Manual handling of message parsing needed
  • Not suitable for high-frequency, low-latency scenarios without tuning

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Pub

All Contributors

ActionCable in Dart

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.

Usage

Connecting to a channel 🙌
cable = ActionCable.connect(
  "ws://10.0.2.2:3000/cable",
  headers: {
    "Authorization": "Some Token",
  },
  onConnected: (){
    print("connected");
  },
  onConnectionLost: () {
    print("connection lost");
  },
  onCannotConnect: () {
    print("cannot connect");
});
Subscribing to channel 🎉
cable.subscribe(
  "Chat", // either "Chat" and "ChatChannel" is fine
  channelParams: { "room": "private" },
  onSubscribed: (){}, // `confirm_subscription` received
  onDisconnected: (){}, // `disconnect` received
  onMessage: (Map message) {} // any other message received
);
Unsubscribing from a channel 🎃
cable.unsubscribe(
  "Chat", // either "Chat" and "ChatChannel" is fine
  {"room": "private"}
);
Perform an action on your ActionCable server 🎇

Requires that you have a method defined in your Rails Action Cable channel whose name matches the action property passed in.

cable.performAction(
  "Chat",
  action: "send_message",
  channelParams: { "room": "private" },
  actionParams: { "message": "Hello private peeps! 😜" }
);
Disconnect from the ActionCable server
cable.disconnect();

ActionCable protocol

Anycable has a great doc on that topic.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Clinton

💻 ⚠️

Hamad AlGhanim

💻

Fareesh Vijayarangam

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.