Browse SDKs · Flutter
Platform
SDKsFlutter

Load older message history

Use the Flutter SDK to page backward through a conversation's historical messages.

Copy

Page backward through historical chat records in a conversation as the user scrolls upward:

Parameters

ParameterTypeRequiredDescription
conversationIDStringYesTarget conversation ID.
startMsgMessage?NoStarting cursor message. Pass null for the first page; pass the earliest loaded message for subsequent pages.
countintYesNumber of messages to retrieve in this batch.
viewTypeint?NoHistory view type, defaulting to normal history (GetHistoryViewType.history).

Code example

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

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

Return value

Returns a Future resolving to an advanced message pagination object (AdvancedMessage). The messageList field contains the retrieved batch of messages, and isEnd indicates whether the earliest historical message has been reached.

When isEnd == true, no earlier historical records remain in local storage or on the server; stop further upward paging requests.

State changes after the call

This query retrieves a point-in-time snapshot and does not trigger new-message event callbacks. Deduplicate local message lists strictly using non-empty clientMsgID values. To page forward toward newer messages from a search result or quote anchor, see Load newer message history and Locate messages by ID.