Skip to content
pubscout

phoenix_socket

0.8.0, released 2 years ago by braver.health

Dart implementation of Phoenix Sockets and Channels over WebSockets.

WASM-ready
$ flutter pub add phoenix_socket
Source repository

What it does

PhoenixSocket provides a feature-complete implementation of Phoenix Sockets using StreamChannels, allowing Dart and Flutter applications to interact with Phoenix Channels and Presence over WebSockets. It replicates the JavaScript Phoenix client API while leveraging Dart's native Streams and Futures.

AI-written summary of version 0.8.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to connect a Flutter app to a Phoenix backend using Channels.
  • You want real-time bi-directional communication via WebSockets using a familiar Phoenix socket API.

Skip it when

  • You are communicating with a standard REST or GraphQL backend instead of Phoenix Sockets.
  • You require a completely out-of-the-box solution for non-Phoenix WebSocket servers without adapting to the Phoenix protocol.

Strengths

  • Consistent API across web and native environments using web_socket_channel.
  • Built-in support for auto-reconnection and channel management.

Weaknesses

  • Presence support is currently experimental.
  • Limited specifically to the Phoenix framework's channel protocol.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3

Add the dependency to pubspec.yaml and import it.

import 'package:phoenix_socket/phoenix_socket.dart';

final socket = PhoenixSocket('ws://localhost:4000/socket/websocket');
await socket.connect();

Alternatives

Packages that do the same job and could replace phoenix_socket.

Works with

Packages commonly used together with phoenix_socket: ones it builds on, ones built on it, and its own family.