Retrieve conversation list
Retrieve the current user conversation list using pagination in the OpenIM Flutter SDK.
The conversation list belongs to the currently signed-in user. Each ConversationInfo record encapsulates the conversation identifier, unread count, latest message, pin state, and draft text. Read the conversation list with pagination starting at offset: 0 for the first page:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
offset | int | Yes | Zero-based pagination offset index; reset to 0 when refreshing the list. |
count | int | Yes | Number of conversation items to fetch per page. |
Code example
const pageSize = 50;
Future<List<ConversationInfo>> loadConversationPage(int offset) async {
final page = await OpenIM.iMManager.conversationManager
.getConversationListSplit(offset: offset, count: pageSize);
mergeConversations(page);
return page;
}Return value
A successful Future returns a list of conversations for the requested page (List<ConversationInfo>). For subsequent pages, increment offset by the number of retrieved items. The client deduplicates and merges entries using conversationID as the unique key. If the returned count is less than count, the end of the list has been reached. When performing a pull-to-refresh, reset offset back to 0.
Maintain real-time synchronization
Paginated queries fetch snapshot state at invocation time and do not emit listener events. Synchronize real-time state transitions through the application's centralized OnConversationListener:
void handleNewConversations(List<ConversationInfo> conversations) {
mergeConversations(conversations);
}
void handleConversationsChanged(List<ConversationInfo> conversations) {
mergeConversations(conversations);
}Both onNewConversation and onConversationChanged deliver updated List<ConversationInfo> arrays. Merge them into the active list using conversationID as the primary key. For centralized listener configuration, see Events overview.
Do not substitute joined group lists for the conversation list. A user may join a group before a conversation record is instantiated, or retain historical conversation entries after leaving a group.
Was this page helpful?