Skip to content
pubscout

eventflux

3.0.2, released 8 weeks ago by gokula.dev

A Server-Sent Events client for Dart and Flutter with auto-reconnection.

WASM-ready
$ flutter pub add eventflux
Source repository

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.

Works with

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