AgentComposerController class

The draft behind an Agent composer, with the rules for sending it.

It is a TextEditingController, so the composer's text field uses it directly. It adds the run state (running) and the send rules: when the draft can be sent (canSubmit), taking it (submit), and what a key press does (handleKeyEvent).

Enter sends. Shift+Enter and Enter during IME composition belong to the field. Enter never becomes a newline in a composer that sends, even when there is nothing to send or a run is live, and a held Enter sends once.

Inheritance

Constructors

AgentComposerController({String? text, bool running = false, bool clearOnSubmit = true})
Creates a composer draft holding text.
AgentComposerController.fromValue(TextEditingValue? value, {bool running = false, bool clearOnSubmit = true})
Creates a composer draft from an existing editing value.

Properties

canSubmit → bool
Whether the draft can be sent now: there is a draft and no run is live.
no setter
clearOnSubmit ↔ bool
Whether submit empties the field after taking the draft.
getter/setter pair
hasDraft → bool
Whether the draft has something to send: any text besides whitespace.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
isComposing → bool
Whether an input method is composing text. Enter then confirms the composition, not the message.
no setter
running ↔ bool
Whether a run is live. While it is, the draft cannot be sent and the composer offers to stop instead.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selection ↔ TextSelection
The currently selected range within text.
getter/setter pairinherited
text ↔ String
The current string the user is editing.
getter/setter pairinherited
value ↔ TextEditingValue
The current value stored in this notifier.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
buildTextSpan({required BuildContext context, TextStyle? style, required bool withComposing}) → TextSpan
Builds TextSpan from current editing value.
inherited
clear() → void
Set the value to empty.
inherited
clearComposing() → void
Set the composing region to an empty range.
inherited
dispose() → void
Discards any resources used by the object.
inherited
handleKeyEvent(KeyEvent event, {required ValueChanged<String>? onSubmit, bool allowSubmit = true}) → KeyEventResult
Applies the composer's Enter rules to event.
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
submit() → String?
Takes the draft for sending.
toString() → String
A string representation of this object.
inherited

Operators

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