Poll class

Class representing a poll. A poll instance can be created using Poll.create with PollCreateParams and updated using GroupChannelPoll.updatePoll with PollUpdateParams class. A poll can be attached to a message using UserMessageCreateParams.pollId.



Poll({required int id, required String title, required int createdAt, required int updatedAt, required int closeAt, required PollStatus status, int? messageId, PollData? data, int voterCount = -1, List<PollOption> options = const [], String? createdBy, bool allowUserSuggestion = false, bool allowMultipleVotes = false, List<int>? votedPollOptionIds})
Poll.fromJson(Map<String, dynamic> json)


allowMultipleVotes bool
True if this poll allows multiple votes, false otherwise.
read / write
allowUserSuggestion bool
True if this poll allows user suggestion, false otherwise.
read / write
closeAt int
Unix timestamp at which the poll has closed or will close. (second precision) If poll closing time is not specified, this value will be -1.
read / write
createdAt int
Unix timestamp at which the poll is created (ms).
createdBy String?
UserId of the poll creator. null if the creator account is removed.
data PollData?
An additional json data to accompany the poll.
read / write
hashCode int
The hash code for this object.
id int
A unique identifier for this poll.
messageId int?
A id of the message that contains this poll
options List<PollOption>
Options for this poll.
read / write
runtimeType Type
A representation of the runtime type of the object.
status PollStatus
Indicates whether this poll is PollStatus.open, or PollStatus.closed
read / write
title String
Title of the poll.
read / write
updatedAt int
Unix timestamp at which the poll is updated (ms).
read / write
votedPollOptionIds List<int>?
Contains optionIds which the current user voted on. If the current user has not voted, this list will be empty.
read / write
voterCount int
Total voter count.
read / write


applyPollUpdateEvent(PollUpdateEvent event) bool
Applies poll update event to this user message's poll.
applyPollVoteEvent(PollVoteEvent event) bool
Applies poll vote event to this user message's poll.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toJson() Map<String, dynamic>
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.

Static Methods

create(PollCreateParams params, {Chat? chat}) Future<Poll>
Builds Poll instance with given params instance.
get(PollRetrievalParams params, {Chat? chat}) Future<Poll>
Retrieves latest poll matching PollRetrievalParams.pollId instance from server.