eventflux
3.0.2, released 8 weeks ago by gokula.dev
A Server-Sent Events client for Dart and Flutter with auto-reconnection.
What it does
Handles connection, parsing, and data management for Server-Sent Events (SSE) streams in Dart and Flutter. It supports auto-reconnection with backoff, interceptors, mid-flight request aborts, and web platform integration.
AI-written summary of version 3.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Your application needs to consume a Server-Sent Events (SSE) stream from a backend
- You require automatic reconnection logic with exponential or linear backoff
- You need web support for SSE streams with CORS and custom headers
Skip it when
- Your backend uses traditional REST requests without streaming
- You are building a real-time bidirectional feature that strictly requires WebSockets instead of server-to-client streaming
Strengths
- WHATWG SSE spec-compliant parsing with lastEventId and retry support
- Built-in auto-reconnection with exponential and linear backoff, jitter, and max backoff capping
- Supports interceptors, mid-flight aborts, and idle timeout detection
Weaknesses
- Limited primarily to Server-Sent Events rather than full WebSocket bidirectional messaging
- Requires webConfig setup specifically on the web platform
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Requires Dart SDK >=3.4.0 and Flutter >=3.0.0. On web, requires passing a WebConfig instance to the connect method.
import 'package:eventflux/eventflux.dart';
void main() {
EventFlux.instance.connect(
EventFluxConnectionType.get,
'https://example.com/events',
onSuccessCallback: (EventFluxResponse? response) {
response?.stream?.listen((EventFluxData data) {
print('Event: ${data.event}');
print('Data: ${data.data}');
});
},
);
}Alternatives
Packages that do the same job and could replace eventflux.
- sse
Bidirectional Server Sent Events client and server for Dart.
80Compare - sse_channel
Wraps Server‑Sent Events as a StreamChannel for Dart IO and web
56Compare - flutter_client_sse
Consume Server-Sent Events (SSE) APIs with support for GET and POST requests.
50Compare - flutter_http_sse
Flutter client library for receiving Server-Sent Events (SSE) over HTTP.
51Compare
Works with
Packages commonly used together with eventflux: ones it builds on, ones built on it, and its own family.