fetchMemberAttributes method

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

获取单个群成员所有自定义属性。

Param groupId 群组 ID。 Param userId 要获取属性的群成员用户 ID。

Return 群成员自定义属性键值对。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 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;
  }
}