actionButton property
Represents a send button.
The SfAIAssistView widget does not include an action button by default. To add, create a new instance of AssistActionButton.
If the AssistActionButton.onPressed callback is null, the button remains disabled.
If the default composer's text is empty or if the composer is disabled, the button remains disabled.
If the composer is null, the button always stays enabled.
If last message is AssistMessage.request, the button will be disabled until the next AssistMessage.response is added.
Pressing the action button invokes the AssistActionButton.onPressed callback with the text entered in the default composer. By default, SfAIAssistView will not update its state until the parent widget rebuilds the chat with new messages.
If AssistComposer.builder is used, the button always stays enabled.
List<AssistMessage> _messages = <AssistMessage>[
AssistMessage.response(
data: 'Hello, how can I help you today?',
),
];
@override
Widget build(BuildContext context) {
return SfAIAssist(
messages: _messages,
outgoingUser: '8ob3-b720-g9s6-25s8',
actionButton: AssistActionButton(
onPressed: (String newMessage) {
setState(() {
_messages.add(
AssistMessage.request(
data: newMessage,
),
);
});
},
),
);
}
See also:
- AssistComposer to customize the default text editor.
- AssistComposer.builder to create a custom text editor.
- AssistActionButton.onPressed to handle the action button click.
- AssistActionButton.child to add new action buttons.
Implementation
final AssistActionButton? actionButton;