Skip to main content
Version: v4

Customize Message Actions

Customizing Message Actions

Introduction#

Message actions pop up in message overlay, when you long-press a message.

We have provided granular control over these actions.

By default we render the following message actions:

  • edit message

  • delete message

  • reply

  • thread reply

  • copy message

  • flag message

  • pin message

note

Edit and delete message are only available on messages sent by the user. Additionally, pinning a message requires you to add the roles which are allowed to pin messages.

Partially remove some message actions#

For example, if you only want to keep "copy message" and "delete message", here is how to do it using the messageBuilder with our StreamMessageWidget.

StreamMessageListView(
messageBuilder: (context, details, messages, defaultMessage) {
return defaultMessage.copyWith(
showFlagButton: false,
showEditMessage: false,
showCopyMessage: true,
showDeleteMessage: details.isMyMessage,
showReplyMessage: false,
showThreadReplyMessage: false,
);
},
)

Add a new custom message action#

The SDK also allows you to add new actions into the dialog.

For example, let's suppose you want to introduce a new message action - "Demo Action":

We use the customActions parameter of the StreamMessageWidget to add extra actions.

StreamMessageListView(
messageBuilder: (context, details, messages, defaultMessage) {
return defaultMessage.copyWith(
customActions: [
StreamMessageAction(
leading: Icon(Icons.add),
title: Text('Demo Action'),
onTap: (message) {
/// Complete action here
},
),
],
);
},
)

Did you find this page helpful?