AgentMessage class

One message of a conversation: the reader's bubble or the assistant's reply.

A AgentRole.user message sits at the end of the line, as wide as its text up to AgentMessageSpec.maxWidthFactor of the line. When it is taller than AgentMessageSpec.collapsedHeight, it shows that much and offers "Show more"; the clipped text stays readable to assistive technology.

An AgentRole.assistant message spans the line and never collapses. Its header and footer slots hold what surrounds the reply, such as a name or actions.

Style each role with AgentMessageStylerRole.onUser and AgentMessageStylerRole.onAssistant.

Inheritance

Constructors

AgentMessage({Key? key, required AgentRole role, required Widget child, Widget? header, Widget? footer, String? semanticLabel, bool? expanded, bool defaultExpanded = false, ValueChanged<bool>? onExpandedChanged, String showMoreLabel = 'Show more', String showLessLabel = 'Show less', ButtonStyler toggleStyle = const ButtonStyler.create(), AgentMessageStyler style = const AgentMessageStyler.create(), AgentMessageSpec? styleSpec})
Creates a message from role holding child.
const

Properties

child → Widget
The message content, usually text.
final
defaultExpanded → bool
Whether a long user message starts in full when uncontrolled.
final
expanded → bool?
Whether a long user message shows in full. Null lets the message own the state, starting at defaultExpanded.
final
Shown below the content.
final
hashCode → int
The hash code for this object.
no setterinherited
Shown above the content.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onExpandedChanged → ValueChanged<bool>?
Receives each request to show a long user message in full or not.
final
role → AgentRole
Who wrote the message.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel → String?
The message's accessible name; defaults to "User message" or "Assistant message".
final
showLessLabel → String
The label of the action that collapses a long user message again.
final
showMoreLabel → String
The label of the action that shows a long user message in full.
final
style → AgentMessageStyler
The message's style.
final
styleSpec → AgentMessageSpec?
A resolved spec that bypasses style.
final
toggleStyle → ButtonStyler
The style of the show more and show less action.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<AgentMessage>
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