/ SDKs / Flutter
SDKs
Chat SDKs Flutter v3
Chat SDKs Flutter
Chat SDKs
Flutter
Version 3
Sendbird Chat SDK v3 for Flutter is no longer supported as a new version is released. Check out our latest Chat SDK v4

Categorize messages by custom type

Copy link

When sending a message, you can specify a custom message type to subclassify messages. This custom type takes on the form of String and can be useful in searching or filtering messages.

The data and customType properties of a message object allow you to append information to your messages. While both properties can be used flexibly, common examples for customType include grouping messages into categories such as Notes or Contacts.

To embed a custom type into your message, assign a value to customType under the UserMessageParams or FileMessageParams object. Then, pass the specified object as an argument to the parameter in the sendUserMessage() or sendFileMessage() method.

To get a message's custom type, read message.customType.

Note: Starting from Flutter Chat SDK 3.1.0, the UserMessageParams constructor requires the message parameter.

final params = UserMessageParams(message: MESSAGE)
    ..customType = CUSTOM_TYPE;

try {
    final preMessage = await groupChannel.sendUserMessage(params, onCompleted: (msg, err) {
        // The message has been sent successfully.
    });
} catch (e) {
    // Handle error.
}

</div>