Search packages, repositories and app categories

Package detailsv0.4.0

eventsource

A client and server implementation of Server-Sent Events.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
595
Likes
30
Pub points
120

Install package

flutter pub add eventsource

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Dart package providing client and server implementations for Server-Sent Events (SSE), enabling real-time, one-way communication from server to client. It supports streaming events over HTTP, making it ideal for live updates, notifications, and data feeds. The package is compatible across all major platforms including Android, iOS, Web, macOS, Windows, and Linux. It follows the SSE standard with support for event IDs, retry intervals, and custom event types. The implementation is lightweight and integrates smoothly into Flutter and Dart applications.

Use cases

  • Live notifications
  • Real-time data streaming
  • Server-side event broadcasting
  • Status updates in web apps
  • Interactive dashboards
  • Log streaming

Key features

  • Full SSE protocol support
  • Cross-platform compatibility
  • Event ID and retry handling
  • Custom event type support
  • Lightweight and efficient
  • Easy integration with Flutter

Suitable for

  • Real-time app features
  • Backend services needing push capabilities
  • Apps requiring low-latency updates
  • Web and mobile apps with live content
  • Developers using Dart/Flutter for full-stack apps

Considerations

  • Not suitable for bidirectional communication
  • Requires a compatible server implementation
  • Limited to server-to-client streaming
  • May need additional setup for authentication
  • Best suited for high-frequency, low-latency updates

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

eventsource

A library for using EventSource or Server-Sent Events (SSE). Both client and server functionality is provided.

This library implements the interface as described here.

Client usage

For more advanced usage, see the example/ directory. Creating a new EventSource client is as easy as a single call. The http package is used under the hood, so wherever this package works, this library will also work. Browser usage is slightly different.

EventSource eventSource = await EventSource.connect("http://example.com/events");
// in browsers, you need to pass a http.BrowserClient:
EventSource eventSource = await EventSource.connect("http://example.com/events", 
    client: new http.BrowserClient());

Server usage

We recommend using shelf_eventsource for serving Server-Sent Events. This library provides an EventSourcePublisher that manages subscriptions, channels, encoding. We refer to documentation in the shelf_eventsource package for more information.

This library also includes a server provider for dart:io's HttpServer in io_server.dart. However, it has some issues with data flushing that are yet to be resolved, so we recommend using shelf instead.

Licensing

This project is available under the MIT license, as can be found in the LICENSE file.

Categories

Dependencies

Dependency list 5 items

Source repository

Projects using this package

No data available yet.