ChatWidget class
A StatefulWidget that provides a complete chat UI.
It manages the underlying ChatService, displays messages using ChatBubble, and provides a text input field for sending messages.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ChatWidget
Constructors
-
ChatWidget.new({Key? key, required String domain, required String chatbotId, ChatTheme? theme, void onMessageSent(String message)?, void onResponseReceived(String response)?, void onCitationsReceived(List<
Map< citations)?, void onThreadIdReceived(String threadId)?, void onError(dynamic error)?, List<String, dynamic> >ChatMessage> ? initialMessages, String? inputPlaceholder, IconData? sendButtonIcon, bool showTimestamps = false, bool useThemeOverride = false, bool showCitations = false, bool isEnabled = true}) -
const
Properties
- chatbotId → String
-
The specific Chatbot ID to connect to.
final
- domain → String
-
Domain for the chat API backend.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
initialMessages
→ List<
ChatMessage> ? -
A list of messages to display initially when the widget loads.
final
- inputPlaceholder → String?
-
Placeholder text displayed in the message input field.
final
- isEnabled → bool
-
Flag to enable/disable the entire chat widget functionality.
If disabled, input is blocked, and initialization might not occur.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onCitationsReceived
→ void Function(List<
Map< citations)?String, dynamic> > -
Callback for when citations are received (optional).
final
- onError → void Function(dynamic error)?
-
Callback invoked when any error occurs during initialization or message handling.
final
- onMessageSent → void Function(String message)?
-
Callback invoked when the user successfully sends a message.
final
- onResponseReceived → void Function(String response)?
-
Callback invoked when a complete response (content part) is received.
Note: The UI updates reactively; this is for external logic if needed.
final
- onThreadIdReceived → void Function(String threadId)?
-
Callback for when a new thread ID is received (optional).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sendButtonIcon → IconData?
-
Custom icon for the send button. Defaults to
Icons.send
.final - showCitations → bool
-
Flag to control the visibility of citations within the chat bubbles.
final
- showTimestamps → bool
-
Whether to display timestamps next to each message bubble.
final
- theme → ChatTheme?
-
Theme configuration for customizing the chat appearance.
Merged with the application's theme by default.
final
- useThemeOverride → bool
-
If true, forces the use of the provided theme exclusively,
ignoring the application's
ThemeData
. Defaults to false.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ChatWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited