fromJson static method

SupergroupFullInfo? fromJson(
  1. Map<String, dynamic>? json
)

Implementation

static SupergroupFullInfo? fromJson(Map<String, dynamic>? json) {
  if (json == null) {
    return null;
  }

  return SupergroupFullInfo(
    photo: ChatPhoto.fromJson(tdMapFromJson(json['photo'])),
    communityId: (json['community_id'] as int?) ?? 0,
    description: (json['description'] as String?) ?? '',
    memberCount: (json['member_count'] as int?) ?? 0,
    administratorCount: (json['administrator_count'] as int?) ?? 0,
    restrictedCount: (json['restricted_count'] as int?) ?? 0,
    bannedCount: (json['banned_count'] as int?) ?? 0,
    linkedChatId: (json['linked_chat_id'] as int?) ?? 0,
    directMessagesChatId: (json['direct_messages_chat_id'] as int?) ?? 0,
    slowModeDelay: (json['slow_mode_delay'] as int?) ?? 0,
    slowModeDelayExpiresIn:
        ((json['slow_mode_delay_expires_in'] as num?) ?? 0.0).toDouble(),
    canEnablePaidMessages:
        (json['can_enable_paid_messages'] as bool?) ?? false,
    canEnablePaidReaction:
        (json['can_enable_paid_reaction'] as bool?) ?? false,
    canGetMembers: (json['can_get_members'] as bool?) ?? false,
    hasHiddenMembers: (json['has_hidden_members'] as bool?) ?? false,
    canHideMembers: (json['can_hide_members'] as bool?) ?? false,
    canSetStickerSet: (json['can_set_sticker_set'] as bool?) ?? false,
    canSetLocation: (json['can_set_location'] as bool?) ?? false,
    canGetStatistics: (json['can_get_statistics'] as bool?) ?? false,
    canGetRevenueStatistics:
        (json['can_get_revenue_statistics'] as bool?) ?? false,
    canGetStarRevenueStatistics:
        (json['can_get_star_revenue_statistics'] as bool?) ?? false,
    canSendGift: (json['can_send_gift'] as bool?) ?? false,
    canToggleAggressiveAntiSpam:
        (json['can_toggle_aggressive_anti_spam'] as bool?) ?? false,
    isAllHistoryAvailable:
        (json['is_all_history_available'] as bool?) ?? false,
    canHaveSponsoredMessages:
        (json['can_have_sponsored_messages'] as bool?) ?? false,
    hasAggressiveAntiSpamEnabled:
        (json['has_aggressive_anti_spam_enabled'] as bool?) ?? false,
    hasPaidMediaAllowed: (json['has_paid_media_allowed'] as bool?) ?? false,
    hasPinnedStories: (json['has_pinned_stories'] as bool?) ?? false,
    giftCount: (json['gift_count'] as int?) ?? 0,
    myBoostCount: (json['my_boost_count'] as int?) ?? 0,
    unrestrictBoostCount: (json['unrestrict_boost_count'] as int?) ?? 0,
    outgoingPaidMessageStarCount:
        (json['outgoing_paid_message_star_count'] as int?) ?? 0,
    stickerSetId:
        int.tryParse((json['sticker_set_id'] as dynamic)?.toString() ?? '') ??
        0,
    customEmojiStickerSetId:
        int.tryParse(
          (json['custom_emoji_sticker_set_id'] as dynamic)?.toString() ?? '',
        ) ??
        0,
    location: ChatLocation.fromJson(tdMapFromJson(json['location'])),
    inviteLink: ChatInviteLink.fromJson(tdMapFromJson(json['invite_link'])),
    guardBotUserId: (json['guard_bot_user_id'] as int?) ?? 0,
    botCommands: List<BotCommands>.from(
      tdListFromJson(json['bot_commands'])
          .map((item) => BotCommands.fromJson(tdMapFromJson(item)))
          .whereType<BotCommands>(),
    ),
    botVerification: BotVerification.fromJson(
      tdMapFromJson(json['bot_verification']),
    ),
    mainProfileTab: ProfileTab.fromJson(
      tdMapFromJson(json['main_profile_tab']),
    ),
    upgradedFromBasicGroupId:
        (json['upgraded_from_basic_group_id'] as int?) ?? 0,
    upgradedFromMaxMessageId:
        (json['upgraded_from_max_message_id'] as int?) ?? 0,
  );
}