Skip to content
pubscout

websocket_universal

1.4.0, released 3 weeks ago by dvmatyun.ru

Cross‑platform WebSocket client with auto‑reconnect, ping measurement and typed message support

$ flutter pub add websocket_universal
Source repository

What it does

Provides a unified WebSocket API for web, mobile and desktop. It handles connection state, ping/pong, auto‑reconnect and offers a generic message processor for typed payloads.

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

Use it when

  • Real‑time chat or collaboration apps
  • Live data feeds or dashboards
  • Any scenario needing reliable WebSocket communication across platforms

Skip it when

  • Simple one‑off WebSocket usage where a lightweight library is sufficient
  • Projects that already use a dedicated WebSocket client like web_socket_channel

Strengths

  • Cross‑platform support (IO + web)
  • Auto‑reconnect and ping/pong handling
  • Typed message processing via IMessageProcessor
  • Stream‑based API for easy integration with async code

Weaknesses

  • No active code generation support
  • Limited documentation on advanced configuration
  • Not as widely used as web_socket_channel, so community support is smaller

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
3

Add dependency, import package, create handler and listen to streams – no extra build_runner or permissions needed

import 'package:websocket_universal/websocket_universal.dart';

final handler = IWebSocketHandler<String, String>.createClient(
  'wss://example.com/ws',
  SocketSimpleTextProcessor(),
);

handler.socketHandlerStateStream.listen((s) => print('state: $s'));
handler.incomingMessagesStream.listen((msg) => print('msg: $msg'));
await handler.connect();
handler.sendMessage('hello');

Alternatives

Packages that do the same job and could replace websocket_universal.

Works with

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