Browse SDKs · Flutter
Platform
SDKsFlutterEnterprise

Pin or unpin a message

Use the Flutter SDK to pin or unpin a message in a conversation.

Copy

Pin a specific message to the top of a conversation, or unpin a previously pinned message:

Parameters

ParameterTypeRequiredDescription
conversationIDStringYesTarget conversation ID.
clientMsgIDStringYesTarget client message ID to pin or unpin.
pinnedboolYesPinning state: true to pin; false to unpin.

Code example

await OpenIM.iMManager.messageManager.setConversationPinnedMsg(
  conversationID: conversationID,
  clientMsgID: clientMsgID,
  pinned: true,
);

Return value

Future completion indicates that the server accepted the pin or unpin request.

Future completion does not guarantee that event notifications have arrived at all clients. Update local conversation pin states optimistically if desired; to retrieve the complete current list of pinned messages, see Retrieve pinned conversation messages.

State changes after the call

Pinned message changes trigger the onChangedPinnedMsg callback in OnAdvancedMsgListener. When another client or an administrator updates pinned messages, participants in the conversation receive this callback. Locate the target conversation by conversationID and merge or replace the pinned message list deduplicating items by clientMsgID. For centralized listener registration, see Events overview.