AgentAnswer class

The assistant's answer: a body, its sources and an actions bar.

child is the body, such as the answer's markdown. It is never a live region, so a screen reader does not read the answer token by token; the host announces it once it is ready (see AgentAnnouncer).

Once the answer stops streaming, the actions bar offers copy, thumbs up, thumbs down and retry, each when its callback is set. Copying shows copiedLabel for copiedDuration as a status message, announced without moving focus. The thumbs are toggles that report through onFeedback.

sources sits between the body and the actions, usually an AgentSources. A new streaming run, such as a retry, rebuilds it, so it starts collapsed again.

Inheritance

Constructors

AgentAnswer({Key? key, required Widget child, AgentAnswerStatus status = AgentAnswerStatus.complete, Object? id, Widget? sources, bool? showActions, VoidCallback? onCopy, AgentAnswerFeedback? feedback, ValueChanged<AgentAnswerFeedback?>? onFeedback, VoidCallback? onRetry, String copyLabel = 'Copy', String copiedLabel = 'Copied', String positiveLabel = 'Good response', String negativeLabel = 'Bad response', String retryLabel = 'Retry', Duration copiedDuration = const Duration(seconds: 2), String semanticLabel = 'Answer', AgentGlyphBuilder? glyphBuilder, IconButtonStyler actionStyle = const IconButtonStyler.create(), IconButtonStyler selectedActionStyle = const IconButtonStyler.create(), AgentAnswerStyler style = const AgentAnswerStyler.create(), AgentAnswerSpec? styleSpec})
Creates an answer with the body child.
const

Properties

actionStyle → IconButtonStyler
The style of every action.
final
child → Widget
The answer's body.
final
copiedDuration → Duration
How long copiedLabel shows.
final
copiedLabel → String
The status message after copying.
final
copyLabel → String
The accessible name of copy.
final
feedback → AgentAnswerFeedback?
The reader's current verdict.
final
glyphBuilder → AgentGlyphBuilder?
Draws the glyphs; defaults to the nearest AgentGlyphs.
final
hashCode → int
The hash code for this object.
no setterinherited
id → Object?
The answer's identity; a new identity that streams starts a new run.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
negativeLabel → String
The accessible name of thumbs down.
final
onCopy → VoidCallback?
Copies the answer; the bar then shows copiedLabel.
final
onFeedback → ValueChanged<AgentAnswerFeedback?>?
Receives the reader's new verdict, or null when they take it back.
final
onRetry → VoidCallback?
Asks for the answer again.
final
positiveLabel → String
The accessible name of thumbs up.
final
retryLabel → String
The accessible name of retry.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedActionStyle → IconButtonStyler
Merged into actionStyle for the selected feedback button.
final
semanticLabel → String
The answer's accessible name.
final
showActions → bool?
Whether the actions bar shows once the answer stops streaming; defaults to AgentAnswerStatus.showsActions.
final
sources → Widget?
The answer's sources, usually an AgentSources.
final
status → AgentAnswerStatus
Whether the answer streams, is complete or failed.
final
style → AgentAnswerStyler
The answer's style.
final
styleSpec → AgentAnswerSpec?
A resolved spec that bypasses style.
final

Methods

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