Retrieve users
Batch query public user profiles (PublicUserInfo) by userID using the OpenIM Flutter SDK.
Batch query public profiles of application users by userID, ideal for rendering friend candidates and stranger profile cards:
When searching users by nickname, phone number, organization, or email, your business backend should first return matching userID values. Then call this method to retrieve their public profile details.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userIDList | List<String> | Yes | List of user IDs to query for public information. Deduplicate entries and cap batch sizes before calling. |
Code example
final userIDList = {'user_a', 'user_b'}.toList();
try {
final users = await OpenIM.iMManager.userManager.getUsersInfo(
userIDList: userIDList,
);
final usersByID = {
for (final user in users)
if (user.userID != null) user.userID!: user,
};
showUsers(usersByID);
} catch (error) {
logUserQueryFailure(error, userIDList);
rethrow;
}Return value
A successful Future returns a list of public user profiles (List<PublicUserInfo>):
| Field | Type | Description |
|---|---|---|
userID | String | Unique OpenIM user identifier. |
nickname | String? | Account-level public display nickname. |
faceURL | String? | Account-level public avatar URL. |
ex | String? | Account-level extension string formatted per business conventions. |
The returned ex is read-only when viewing other accounts. The Flutter client cannot modify other users' profiles; to update the current user's profile, see Update self profile.
This query is a local read-only operation and does not trigger user listener events. Re-invoke this API to fetch fresh data when opening profile cards, pulling to refresh, reconnecting, or receiving business update notifications.
Model selection by context
The same userID may possess different display names and relationship data across contexts. Select the appropriate data model for each view:
| Context | Recommended Model |
|---|---|
| User directory search, stranger profile cards | PublicUserInfo |
| Friend lists, contact cards, friend remarks | FriendInfo |
| Group rosters, in-group nicknames, group roles | GroupMembersInfo |
Friend remarks and group nicknames originate from friendship and group membership records; do not overwrite them with PublicUserInfo.nickname. For related queries, see Get friend list with pagination, Get friends info, and Retrieving group members overview.
Was this page helpful?