Poll constructor

const Poll({
  1. @JsonKey(name: 'id') required String id,
  2. @JsonKey(name: 'question') required String question,
  3. @JsonKey(name: 'options') required List<PollOption> options,
  4. @JsonKey(name: 'total_voter_count') required int totalVoterCount,
  5. @JsonKey(name: 'is_closed') required bool isClosed,
  6. @JsonKey(name: 'is_anonymous') required bool isAnonymous,
  7. @JsonKey(name: 'type') required PollType type,
  8. @JsonKey(name: 'allows_multiple_answers') required bool allowsMultipleAnswers,
  9. @JsonKey(name: 'correct_option_id') int? correctOptionId,
  10. @JsonKey(name: 'explanation') String? explanation,
  11. @JsonKey(name: 'explanation_entities') List<MessageEntity>? explanationEntities,
  12. @JsonKey(name: 'open_period') int? openPeriod,
  13. @JsonKey(name: 'close_date') int? closeDate,
  14. @JsonKey(name: 'question_entities') List<MessageEntity>? questionEntities,
})

Constructs a Poll object

Implementation

const factory Poll({
  /// Unique poll identifier
  @JsonKey(name: 'id') required String id,

  /// Poll question, 1-300 characters
  @JsonKey(name: 'question') required String question,

  /// List of poll options
  @JsonKey(name: 'options') required List<PollOption> options,

  /// Total number of users that voted in the poll
  @JsonKey(name: 'total_voter_count') required int totalVoterCount,

  /// True, if the poll is closed
  @JsonKey(name: 'is_closed') required bool isClosed,

  /// True, if the poll is anonymous
  @JsonKey(name: 'is_anonymous') required bool isAnonymous,

  /// Poll type, currently can be "regular" or "quiz"
  @JsonKey(name: 'type') required PollType type,

  /// True, if the poll allows multiple answers
  @JsonKey(name: 'allows_multiple_answers')
  required bool allowsMultipleAnswers,

  /// Optional. 0-based identifier of the correct answer option. Available
  /// only for polls in the quiz mode, which are closed, or was sent (not
  /// forwarded) by the bot or to the private chat with the bot.
  @JsonKey(name: 'correct_option_id') int? correctOptionId,

  /// Optional. Text that is shown when a user chooses an incorrect answer or
  /// taps on the lamp icon in a quiz-style poll, 0-200 characters
  @JsonKey(name: 'explanation') String? explanation,

  /// Optional. Special entities like usernames, URLs, bot commands, etc. that
  /// appear in the explanation
  @JsonKey(name: 'explanation_entities')
  List<MessageEntity>? explanationEntities,

  /// Optional. Amount of time in seconds the poll will be active after
  /// creation
  ///
  /// A handy [Duration] object is available as `openPeriodDuration` getter
  @JsonKey(name: 'open_period') int? openPeriod,

  /// Optional. Point in time (Unix timestamp) when the poll will be
  /// automatically closed
  ///
  /// A handy [DateTime] object is available as `closeDateTime` getter
  @JsonKey(name: 'close_date') int? closeDate,

  /// Optional. Special entities that appear in the question. Currently, only
  /// custom emoji entities are allowed in poll questions
  @JsonKey(name: 'question_entities') List<MessageEntity>? questionEntities,
}) = _Poll;