Browse SDKs · Flutter
SDKsFlutter

Load message history

Use the Flutter SDK to page through a conversation's message history.

Copy

Omit startMsg on the first page. When the user continues scrolling upward, use the earliest complete Message currently loaded as the cursor.

final page = await OpenIM.iMManager.messageManager
    .getAdvancedHistoryMessageList(
  conversationID: conversationID,
  startMsg: oldestMessage,
  count: 30,
  viewType: GetHistoryViewType.history,
);

prependMessages(page.messageList ?? const <Message>[]);

The method returns AdvancedMessage. Stop paging when the list is empty and isEnd == true. Flutter uses a complete message rather than a string ID as the boundary, but the list must still be deduplicated by non-empty clientMsgID values. A query does not trigger the new-message listener.