Skip to content
pubscout

sse

4.2.0, released 7 months ago by tools.dart.dev

Bidirectional Server Sent Events client and server for Dart.

$ flutter pub add sse
Source repository

What it does

Provides a client and server implementation of a bidirectional protocol built on Server‑Sent Events. Both sides expose a sink and a stream so messages can be sent and received. Designed for scenarios where WebSockets are unavailable.

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

Use it when

  • You need real‑time, bidirectional communication in a Dart/Flutter app and WebSockets cannot be used
  • Both client and server are written in Dart and can share the same protocol
  • You want automatic reconnect and out‑of‑order handling for SSE connections

Skip it when

  • You need a general‑purpose SSE library that works with any server implementation
  • You can use WebSockets or other protocols that offer richer features
  • You require support for non‑Dart backends

Strengths

  • Client and server are provided together, ensuring compatibility
  • Handles reconnects, out‑of‑order messages and provides logging
  • Works on web and server platforms

Weaknesses

  • Only works with a matching server from the same package
  • Not a generic SSE client for arbitrary servers
  • Limited to Dart ecosystem

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
7
import 'package:sse/sse.dart';

void main() async {
  final client = SseClient(Uri.parse('https://example.com/sse'));
  client.stream.listen((event) => print('Received: $event'));
  client.sink.add('Hello server');
}

Alternatives

Packages that do the same job and could replace sse.

Works with

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