ServerSentEvent class final
One server-sent event.
The wire format is line-oriented and unforgiving: fields are name: value,
an event ends at a blank line, and a newline inside a value would end the
event early. Multi-line data is therefore sent as one data: line per
line, which is what the specification says and what browsers parse back
into a single string.
Constructors
- ServerSentEvent({String? data, String? event, String? id, Duration? retry, String? comment})
-
Creates an event.
const
- ServerSentEvent.json(Object? value, {String? event, String? id})
-
The payload, encoded as JSON.
factory
Properties
- comment → String?
-
A comment line, which listeners ignore.
final
- data → String?
-
What the event carries.
final
- event → String?
-
The event name a listener can subscribe to by, rather than
message.final - hashCode → int
-
The hash code for this object.
no setterinherited
- id → String?
-
The id a browser echoes back as
Last-Event-IDwhen it reconnects.final - retry → Duration?
-
How long a browser should wait before reconnecting.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
encode(
) → String -
This event in the
text/event-streamformat, blank line included. -
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