/ SDKs / Flutter
Chat SDKs Flutter v3
Chat SDKs Flutter
Chat SDKs
Version 3
Sendbird Chat SDK v3 for Flutter is no longer supported as a new version is released. Check out our latest Chat SDK v4

Cast or cancel a vote

Copy link

You can cast or cancel a vote by passing PollVoteEvent as an argument to a parameter when calling the votePoll() method. Use the optionIds property of the votePoll() method to update the user's final vote choice for a poll. This overrides previous vote actions, so to update previous votes, pass new pollOptionIds as a parameter. To cancel votes, pass an empty list as pollOptionIds.

await channel
    .votePoll(pollId, pollOptionIds);

    // To apply the vote result to the poll, You need to to these.
    // 1. Find a poll by pollVoteEvent.messageId and pollVoteEvent.pollId.
    // 2. Call userMessage.poll.applyPollVoteEvent(event: PollVoteEvent).