Browse SDKs · Flutter
Platform
SDKsFlutter

Retrieve a list of blocked users

Retrieve the current user blocklist using the OpenIM Flutter SDK.

Copy

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:

FieldTypeDescription
userIDStringBlocked target user ID; use as the primary key for state deduplication and lookup.
nicknameString?Target user's nickname.
faceURLString?Target user's avatar URL.
ownerUserIDStringOwner of the blocklist relationship (the currently logged-in user).
blockUserIDStringID of the blocked user in the relation record; use userID for client merges.
operatorUserIDStringUser ID of the operator who executed the block.
createTimeintUnix timestamp in milliseconds when the block was created.
addSourceintNumeric origin source of the block record.
genderintGender enumeration value of the target user.
exString?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.