fromJson static method
Implementation
static User? fromJson(Map<String, dynamic>? json) {
if (json == null) {
return null;
}
return User(
id: (json['id'] as int?) ?? 0,
firstName: (json['first_name'] as String?) ?? '',
lastName: (json['last_name'] as String?) ?? '',
usernames: Usernames.fromJson(tdMapFromJson(json['usernames'])),
phoneNumber: (json['phone_number'] as String?) ?? '',
status: UserStatus.fromJson(tdMapFromJson(json['status'])),
profilePhoto: ProfilePhoto.fromJson(tdMapFromJson(json['profile_photo'])),
accentColorId: (json['accent_color_id'] as int?) ?? 0,
backgroundCustomEmojiId:
int.tryParse(
(json['background_custom_emoji_id'] as dynamic)?.toString() ?? '',
) ??
0,
upgradedGiftColors: UpgradedGiftColors.fromJson(
tdMapFromJson(json['upgraded_gift_colors']),
),
profileAccentColorId: (json['profile_accent_color_id'] as int?) ?? 0,
profileBackgroundCustomEmojiId:
int.tryParse(
(json['profile_background_custom_emoji_id'] as dynamic)
?.toString() ??
'',
) ??
0,
emojiStatus: EmojiStatus.fromJson(tdMapFromJson(json['emoji_status'])),
isContact: (json['is_contact'] as bool?) ?? false,
isMutualContact: (json['is_mutual_contact'] as bool?) ?? false,
isCloseFriend: (json['is_close_friend'] as bool?) ?? false,
verificationStatus: VerificationStatus.fromJson(
tdMapFromJson(json['verification_status']),
),
isPremium: (json['is_premium'] as bool?) ?? false,
isSupport: (json['is_support'] as bool?) ?? false,
restrictionInfo: RestrictionInfo.fromJson(
tdMapFromJson(json['restriction_info']),
),
activeStoryState: ActiveStoryState.fromJson(
tdMapFromJson(json['active_story_state']),
),
restrictsNewChats: (json['restricts_new_chats'] as bool?) ?? false,
paidMessageStarCount: (json['paid_message_star_count'] as int?) ?? 0,
haveAccess: (json['have_access'] as bool?) ?? false,
type: UserType.fromJson(tdMapFromJson(json['type'])),
languageCode: (json['language_code'] as String?) ?? '',
addedToAttachmentMenu:
(json['added_to_attachment_menu'] as bool?) ?? false,
);
}