Skip to content

Sse ​

Category: LLM Providers

Source: sse.dart

Classes ​

SseEvent ​

A single Server-Sent Event.

Constructor ​

dart
SseEvent({this.event, required this.data})

Properties ​

PropertyTypeDescription
eventString?
dataString

Methods ​

String toString() ​

Functions ​

Stream<SseEvent> decodeSse(Stream<List<int>> bytes) ​

Decode a raw byte stream (from an HTTP response) into [SseEvent]s.

Follows the SSE specification:

  • Events are separated by blank lines.
  • Lines starting with : are comments (ignored).
  • data: [DONE] is treated as end-of-stream (OpenAI convention).
  • Multiple data: lines in one event are joined with newlines.

Byte buffering is delegated to utf8.decoder + [LineSplitter] (which handles multi-byte characters and CRLF split across chunk boundaries); this function holds only the SSE field state machine over whole lines.

Released under the MIT License.