Browse SDKs · Flutter
SDKsFlutter

Retrieve a specified conversation

Retrieve one conversation by user or group with the OpenIM Flutter SDK.

Copy

When opening a chat from contacts, a user profile, or a group profile, use getOneConversation(). Pass the other user's ID for a one-to-one chat or the group ID for a group chat. Do not construct ConversationInfo yourself, even when no messages have been sent yet.

final conversation =
    await OpenIM.iMManager.conversationManager.getOneConversation(
  sourceID: targetUserID,
  sessionType: ConversationType.single,
);

openChatPage(conversation: conversation);

Use ConversationType.superGroup for a group chat. A successful Future returns ConversationInfo. The query itself does not trigger a conversation callback; merge subsequent changes through Retrieve the conversation list.