Retrieve a list of blocked users
Retrieve the current user blocklist using the OpenIM Flutter SDK.
Retrieve the full blocklist maintained by the currently logged-in user to build blocklist management views or verify relationship status in profile cards and conversation settings:
Blocklists and group moderation are distinct features. Group mutes, kicking members, or altering group roles belong to group member management; this method queries only the user-level blocklist maintained unilaterally by the current account.
Parameters
This method accepts no parameters.
Code example
final blockedUsers = await OpenIM.iMManager.friendshipManager.getBlacklist();Profile views, conversation menus, and contact directories typically only need to determine whether a given userID is blocked. Construct a lookup Set for fast checks:
final blockedUserIDs = blockedUsers
.map((user) => user.userID)
.whereType<String>()
.toSet();
bool isBlocked(String userID) => blockedUserIDs.contains(userID);Return value
A successful Future returns a list of blocklist entries (List<BlacklistInfo>). An empty list indicates no users are currently blocked.
Each BlacklistInfo object contains the following fields:
| Field | Type | Description |
|---|---|---|
userID | String | Blocked target user ID; use as the primary key for state deduplication and lookup. |
nickname | String? | Target user's nickname. |
faceURL | String? | Target user's avatar URL. |
ownerUserID | String | Owner of the blocklist relationship (the currently logged-in user). |
blockUserID | String | ID of the blocked user in the relation record; use userID for client merges. |
operatorUserID | String | User ID of the operator who executed the block. |
createTime | int | Unix timestamp in milliseconds when the block was created. |
addSource | int | Numeric origin source of the block record. |
gender | int | Gender enumeration value of the target user. |
ex | String? | Custom business extension string. |
If the blocklist UI requires friend remarks or full user profiles, merge records using userID while preserving model boundaries.
This query returns a local database snapshot and does not trigger blocklist addition or deletion events. When opening the blocklist screen or pulling to refresh, call this method to reload the full snapshot. For blocklist mutations, see Block a user and Unblock a user.
Was this page helpful?