fetchMemberAttributes method

Future<Map<String, String>> fetchMemberAttributes({
  1. required String groupId,
  2. String? userId,
})

Gets all custom attributes of a group member.

Param groupId The group ID. Param userId The user ID of the target group member.

Returns The custom attributes map of the group member.

Throws Exception description, see ChatError.

Implementation

Future<Map<String, String>> fetchMemberAttributes({
  required String groupId,
  String? userId,
}) async {
  try {
    Map req = {'groupId': groupId};
    req.putIfNotNull('userId', userId);
    Map result = await platform_interface.Client.instance.groupManager
        .callNativeMethod(ChatMethodKeys.fetchMemberAttributesFromGroup, req);
    ChatError.hasErrorFromResult(result);
    Map<String, String> ret = {};
    result[ChatMethodKeys.fetchMemberAttributesFromGroup]
        .forEach((key, value) {
      ret[key] = value;
    });
    return ret;
  } catch (e) {
    rethrow;
  }
}