AgentComposer class

The prompt input of a conversation: a growing text field over a toolbar with the host's actions and Send, which becomes Stop while a run is live.

The field starts at one line and grows with the draft up to AgentComposerSpec.fieldMaxHeight, then scrolls. A tap anywhere on the composer's surface focuses the field.

controller holds the draft and the run state: while AgentComposerController.running is true, the composer offers Stop instead of Send. Enter sends, Shift+Enter adds a line, and Enter during IME composition belongs to the input method (see AgentComposerController.handleKeyEvent). Without onSubmit, the composer is a plain multiline field.

The surface resolves focused while the field has focus, so a style can mark the whole composer.

Inheritance

Constructors

AgentComposer({Key? key, AgentComposerController? controller, FocusNode? focusNode, ValueChanged<String>? onSubmit, VoidCallback? onStop, bool enabled = true, bool autofocus = false, String hintText = 'Message', String semanticLabel = 'Message', Widget? leading, Widget? trailing, String submitLabel = 'Send', String stopLabel = 'Stop', AgentGlyphBuilder? glyphBuilder, TextFieldStyler fieldStyle = const TextFieldStyler.create(), IconButtonStyler submitStyle = const IconButtonStyler.create(), IconButtonStyler stopStyle = const IconButtonStyler.create(), AgentComposerStyler style = const AgentComposerStyler.create(), AgentComposerSpec? styleSpec})
Creates a composer.
const

Properties

autofocus → bool
Whether the field takes focus when it first builds.
final
controller → AgentComposerController?
The draft and the run state; when null, the composer owns one.
final
enabled → bool
Whether the reader can edit and send.
final
fieldStyle → TextFieldStyler
The style of the text field.
final
focusNode → FocusNode?
The field's focus node; when null, the composer owns one.
final
glyphBuilder → AgentGlyphBuilder?
Draws AgentGlyph.send and AgentGlyph.stop; defaults to the nearest AgentGlyphs.
final
hashCode → int
The hash code for this object.
no setterinherited
hintText → String
The field's placeholder.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leading → Widget?
The host's actions at the toolbar's leading edge, such as attach.
final
onStop → VoidCallback?
Stops the live run.
final
onSubmit → ValueChanged<String>?
Receives the trimmed draft when the reader sends it.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel → String
The composer's accessible name.
final
stopLabel → String
The accessible name of Stop.
final
stopStyle → IconButtonStyler
The style of Stop.
final
style → AgentComposerStyler
The style of the surface and the toolbar.
final
styleSpec → AgentComposerSpec?
A resolved spec that bypasses style.
final
submitLabel → String
The accessible name of Send.
final
submitStyle → IconButtonStyler
The style of Send.
final
trailing → Widget?
The host's actions before Send.
final

Methods

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