Poll.fromJson constructor

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

Parses a Poll from TDLib JSON.

Implementation

factory Poll.fromJson(Map<String, dynamic> json) => Poll(
  id: _readInt(json['id']),
  question: _readObject(json['question'], FormattedText.fromJson),
  options: _readList<PollOption>(
    json['options'],
    (e) => _readObject(e, PollOption.fromJson),
  ),
  totalVoterCount: _readInt(json['total_voter_count']),
  recentVoterIds: _readList<MessageSender>(
    json['recent_voter_ids'],
    (e) => _readObject(e, MessageSender.fromJson),
  ),
  canGetVoters: _readBool(json['can_get_voters']),
  canSeeResults: _readBool(json['can_see_results']),
  isAnonymous: _readBool(json['is_anonymous']),
  allowsMultipleAnswers: _readBool(json['allows_multiple_answers']),
  allowsRevoting: _readBool(json['allows_revoting']),
  membersOnly: _readBool(json['members_only']),
  countryCodes: _readList<String>(json['country_codes'], _readString),
  optionOrder: _readList<int>(json['option_order'], _readInt),
  type: _readObject(json['type'], PollType.fromJson),
  openPeriod: _readInt(json['open_period']),
  closeDate: _readInt(json['close_date']),
  isClosed: _readBool(json['is_closed']),
  voteRestrictionReason: _readOptional(
    json['vote_restriction_reason'],
    PollVoteRestrictionReason.fromJson,
  ),
);