Poll constructor

const Poll({
  1. required String id,
  2. required int votesCount,
  3. int? votersCount,
  4. @JsonKey(name: 'multiple') required bool isMultiple,
  5. @JsonKey(name: 'voted') bool? isVoted,
  6. @JsonKey(name: 'expired') required bool isExpired,
  7. required List<PollOption> options,
  8. List<int>? ownVotes,
  9. required List<Emoji> emojis,
  10. DateTime? expiresAt,
})

Implementation

const factory Poll({
  /// The ID of the poll in the database.
  required String id,

  /// How many votes have been received.
  required int votesCount,

  /// How many unique accounts have voted on a multiple-choice poll.
  ///
  /// It will be `null` if `isMultiple` is `false`.
  int? votersCount,

  /// Does the poll allow multiple-choice answers?
  @JsonKey(name: 'multiple') required bool isMultiple,

  /// When called with a user token, has the authorized user voted?
  @JsonKey(name: 'voted') bool? isVoted,

  /// Is the poll currently expired?
  @JsonKey(name: 'expired') required bool isExpired,

  /// Possible answers for the poll.
  required List<PollOption> options,

  /// When called with a user token, which options has the authorized
  /// user chosen?
  ///
  /// Contains an array of index values for `options`.
  List<int>? ownVotes,

  /// Custom emoji to be used for rendering poll options.
  required List<Emoji> emojis,

  /// When the poll ends.
  ///
  /// If it's `null`, the poll does not end.
  DateTime? expiresAt,
}) = _Poll;