SseEvent class sealed

A sealed base class representing all possible events in a Tuul AI stream.

SseEvent objects are emitted via a Stream during generative processes. Using a sealed class ensures that developers can exhaustively handle all streaming states—such as text generation, tool calling, and lifecycle changes—using a switch statement.

Example:

stream.listen((event) {
  switch (event) {
    case TextDeltaSseEvent(:final text):
      print('New content: $text');
    case ToolCallSseEvent(:final toolName):
      print('AI is calling tool: $toolName');
    case LifecycleSseEvent(type: 'finish'):
      print('Stream complete');
    // ... handle other cases
  }
});
Implementers

Constructors

SseEvent.fromJson(Map<String, dynamic> json)
Factory constructor to map a raw JSON payload from the SSE stream into a specific SseEvent subclass.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
The specific string identifier for the event type.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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