Poll.fromJson constructor

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

Creates a Poll object from JSON object

Implementation

factory Poll.fromJson(Map<String, dynamic> json) {
  return Poll(
    id: json['id']!,
    question: json['question']!,
    options: (json['options'] as List<dynamic>)
        .map((x) => PollOption.fromJson(x as Map<String, dynamic>))
        .toList(),
    totalVoterCount: json['total_voter_count']!,
    isClosed: json['is_closed']!,
    isAnonymous: json['is_anonymous']!,
    type: PollType.fromJson(json['type']!),
    allowsMultipleAnswers: json['allows_multiple_answers']!,
    correctOptionId: json['correct_option_id'],
    explanation: json['explanation'],
    explanationEntities: (json['explanation_entities'] as List<dynamic>?)
        ?.map((x) => MessageEntity.fromJson(x as Map<String, dynamic>))
        .toList(),
    openPeriod: json['open_period'],
    closeDate: json['close_date'],
    questionEntities: (json['question_entities'] as List<dynamic>?)
        ?.map((x) => MessageEntity.fromJson(x as Map<String, dynamic>))
        .toList(),
  );
}