Retrieve the friend list by page
Retrieve the current user’s Flutter friend list by page.
final friends = await OpenIM.iMManager.friendshipManager.getFriendListPage(
offset: 0,
count: 40,
filterBlack: true,
);offset starts at 0, count is the page size, and filterBlack determines whether blocked users are excluded. A successful Future returns the current page as List<FriendInfo>. Append and deduplicate records by userID; receiving fewer items than the page size generally means that the last page has been reached.
Use only the paginated API, not the non-paginated getFriendList(). A query does not trigger the friendship listener.
Synchronize friendship changes
This page owns state handling for onFriendAdded, onFriendInfoChanged, and onFriendDeleted:
void handleFriendChanged(FriendInfo info) {
mergeFriend(info);
}
void handleFriendDeleted(FriendInfo info) {
final userID = info.userID;
if (userID != null) removeFriend(userID);
}The Flutter SDK retains only one OnFriendshipListener. Put these functions in the contacts state layer and set the application-level listener once through the composition entry point described in Events overview. Do not let multiple widgets overwrite the listener. Merge both snapshots and increments by userID.
Was this page helpful?