/ 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

Add extra data to a message

Copy link

You can add extra data to a message in an open or group channel. By storing one or more key-value items to a message, you can use the data to implement various actions in a channel. Based on the items, you can measure user engagement in conversations or count how many times a message has been copied by users in the channel. As shown in the code below, you can add, update, or delete these key-value items anytime. To retrieve the key-values items of a message, use the getMetaArrays() method. When implementing the code below, channel can be openChannel or groupChannel.

Note: To learn more about the types of additional information you can add to a message, see the information types page.

// Add values to existing key-value items.
try {
    final message = await channel.addMessageMetaArray(
        MESSAGE,
        [MessageMetaArray(key: 'referees', values: ['Jane', 'Lynn', 'Julia', 'Katherine']),
        MessageMetaArray(key: 'games', values: ['soccer', 'baseball', 'basketball'])]
    );
} catch (e) {
    // Handle error.
}

// Remove values from existing key-value items.
try {
    final message = await channel.removeMessageMetaArray(
        MESSAGE,
        [MessageMetaArray(key:'referees', values: ['Lynn', 'Katherine'])]
    );
} catch (e) {
    // Handle error.
}

// Delete key-value items by specifying its keys.
try {
    final message = await channel.deleteMessageMetaArrayKeys(
        MESSAGE,
        ['referees', 'games']
    );
} catch (e) {
    // Handle error.
}

Note: Every Sendbird application has a different limit on how many key-value items you can add to a single message, as well as the maximum number of values an item can have. If you wish to learn more about these limits, contact our sales team.