Browse SDKs · Flutter
Platform
SDKsFlutter

Get conversation by target

Retrieve a conversation for a specific user or group using the OpenIM Flutter SDK.

Copy

When initiating a chat from contacts, user profiles, or group details, query the conversation object by target ID and session type. Even if no messages have been exchanged yet, the SDK automatically initializes and returns the corresponding conversation record, avoiding the need to mock data structures at the application layer:

Parameters

ParameterTypeRequiredDescription
sourceIDStringYesTarget chat ID. Supply the counterparty's userID for single chat, or groupID for group chat.
sessionTypeintYesConversation type. Pass ConversationType.single for single chat, or ConversationType.superGroup for group chat.

Code example

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

openChatPage(conversation: conversation);

Return value

A successful Future returns the matching ConversationInfo object.

This query returns an immediate data snapshot and does not emit event notifications. Subsequent conversation property changes are monitored and merged centrally in Retrieve conversation list.