AiChatController class final

A ready-made streaming chat UI built on the prism_ai event model.

Feed it a conversation and a Stream<AiChatMessage> (or wire it to any AiStreamClient yourself via AiChatController), and it renders the conversation with user/assistant bubbles, live typing indicator, and auto-scroll as new content arrives.

final controller = AiChatController();
AiChatView(controller: controller)

Push streaming events into the controller:

await for (final event in client.streamChat(messages, model: 'gpt-4o')) {
  if (event is AiTextDelta) controller.appendAssistantDelta(event.text);
  if (event is AiDone) controller.finishAssistant();
}
Inheritance

Constructors

AiChatController()

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
isStreaming ↔ bool
Whether a response is currently streaming in.
getter/setter pair
messages → List<AiChatMessage>
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
appendAssistantDelta(String text) → void
Appends a chunk of assistant text to the streaming response.
clear() → void
Clears the conversation.
dispose() → void
Discards any resources used by the object.
inherited
finishAssistant() → void
Marks the streaming response as finished.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
reportError(String message) → void
Reports an error as the assistant's response content.
sendUserMessage(String text) → void
Sends a user message and starts a streaming assistant response.
toString() → String
A string representation of this object.
inherited

Operators

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