How to Delete Message Options

Guide Overview

Language/Framework: Flutter UI Kit

UI Kit Version:

"cometchat_chat_uikit: ^4.5.7"

This guide can be used to delete the message options.

Define Custom template according to your requirement.

  final templates = CometChatUIKit.getDataSource().getAllMessageTemplates();
  for (int i = 0; i < templates.length; i++) {
  CometChatMessageTemplate template = templates[i];
  final oldOptions = template.options;
  template.options=(user, message, context ,group){
    List<CometChatMessageOption> options =[];
    if (oldOptions != null) {
      options.addAll(oldOptions(user, message, context, group)??[]);
    }
    options.removeWhere((option) => option.id == MessageOptionConstants.deleteMessage);
    return options;
  };

Message List Configuration

Pass the updated template to the MessageListConfiguration

  MessageListConfiguration messageListConfiguration = MessageListConfiguration(
templates: templates);

Messages Configuration

After defining MessageListConfiguration, pass it to the Messages Configuration.

  MessageConfiguration messageConfiguration = MessageConfiguration(
messageListConfiguration: messageListConfiguration);

Modify the CometChat Component

Use the ConversationsWithMessages component to view the updated message options.

CometChatConversationsWithMessages(messageConfiguration: messageConfiguration)

Default Message options:

Updated Message options: