V2TimUserFullInfo.fromJson constructor
V2TimUserFullInfo.fromJson(
- Map json
Implementation
V2TimUserFullInfo.fromJson(Map json) {
json = Utils.formatJson(json);
userID = json['user_profile_identifier'] ?? "";
nickName = json['user_profile_nick_name'];
faceUrl = json['user_profile_face_url'];
selfSignature = json['user_profile_self_signature'];
gender = json['user_profile_gender'];
int? addPermission = json['user_profile_add_permission'];
allowType = AllowType.V2TIM_FRIEND_ALLOW_ANY;
if (addPermission != null) {
switch (addPermission) {
case CFriendAddPermission.AllowAny:
allowType = AllowType.V2TIM_FRIEND_ALLOW_ANY;
break;
case CFriendAddPermission.NeedConfirm:
allowType = AllowType.V2TIM_FRIEND_NEED_CONFIRM;
break;
case CFriendAddPermission.DenyAny:
allowType = AllowType.V2TIM_FRIEND_DENY_ANY;
break;
default:
allowType = AllowType.V2TIM_FRIEND_ALLOW_ANY;
break;
}
}
var customInfoList = List<Map<String, dynamic>>.from(json['user_profile_custom_string_array'] ?? []);
// C 接口在获取时没有去掉 "Tag_Profile_Custom_" 前缀。
customInfoList = customInfoList.map((item) {
final key = item['user_profile_custom_string_info_key'] as String?;
if (key != null && key.startsWith('Tag_Profile_Custom_')) {
return {
'user_profile_custom_string_info_key': key.replaceFirst('Tag_Profile_Custom_', ''),
'user_profile_custom_string_info_value': item['user_profile_custom_string_info_value']
};
}
return item;
}).toList();
customInfo = Tools.jsonList2Map<String>(
customInfoList, 'user_profile_custom_string_info_key', 'user_profile_custom_string_info_value');
role = json['user_profile_role'];
level = json['user_profile_level'];
birthday = json['user_profile_birthday'];
}