onPressed property

  1. @override
ValueChanged<String>? onPressed
final

A callback function that is called whenever the button is pressed. This parameter is a function that receives a String argument representing the new message. It is Invoked when the button is pressed.

Defaults to null,

Example:


@override
Widget build(BuildContext context) {
  return SfChat(
    actionButton: ChatActionButton(
      onPressed: (String newMessage) {
        setState(() {
          _messages.add(
           ChatMessage(
             text: newMessage,
             time: DateTime.now(),
             author: const ChatAuthor(
               id: '123-001',
               name: 'Chat A',
             ),
           ),
          );
        });
      },
    ),
  );
}

Implementation

@override
final ValueChanged<String>? onPressed;