blockUser static method

Future<Map<String, dynamic>?> blockUser(
  1. List<String>? uids, {
  2. required dynamic onSuccess(
    1. Map<String, dynamic> map
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Block a user from sending logged-in user any messages.

uids list of UID of users to be blocked

receive a map which contains UIDs as the keys and "success" or "fail" as the value based on if the block operation for the UID was successful or not

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<Map<String, dynamic>?> blockUser(List<String>? uids,
    {required Function(Map<String, dynamic> map)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    final result = await channel.invokeMethod('blockUsers', {'uids': uids});
    final res = Map<String, dynamic>.from(result);
    if (onSuccess != null) onSuccess(res);
    return res;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}