Browse SDKs · Flutter
Platform
SDKsFlutter

Retrieve users

Batch query public user profiles (PublicUserInfo) by userID using the OpenIM Flutter SDK.

Copy

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

ParameterTypeRequiredDescription
userIDListList<String>YesList 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>):

FieldTypeDescription
userIDStringUnique OpenIM user identifier.
nicknameString?Account-level public display nickname.
faceURLString?Account-level public avatar URL.
exString?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:

ContextRecommended Model
User directory search, stranger profile cardsPublicUserInfo
Friend lists, contact cards, friend remarksFriendInfo
Group rosters, in-group nicknames, group rolesGroupMembersInfo

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.