SseEvent class

One Server-Sent Event.

The wire format is line-oriented and dispatched by a blank line, so data spanning several lines is emitted as several data: lines, and id/event, which cannot span lines at all, have any newlines stripped.

Constructors

SseEvent(String data, {String? event, String? id, Duration? retry})
Creates an event carrying data.
const
SseEvent.json(Object? value, {String? event, String? id, Duration? retry})
An event whose data is value encoded as JSON.
factory

Properties

data String
The payload delivered to the browser's EventSource as event.data.
final
event String?
The event name. null means the default message type, which a listener receives via onmessage; a name is delivered to addEventListener(name, …) instead.
final
hashCode int
The hash code for this object.
no setterinherited
id String?
The event id. The browser remembers the last one it saw and replays it as the last-event-id header when it reconnects, so a stream can resume.
final
retry Duration?
How long the browser should wait before reconnecting if the stream drops.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

encode() String
This event in SSE wire form, terminated by the blank line that dispatches it.
encodeBytes() List<int>
This event in SSE wire form, as UTF-8 bytes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited