Skip to main content

Introduction

The meetings polls object can be accessed using dyteClient.polls. It provides methods to create polls, vote, and more.

dyteClient.polls.polls returns an array of all polls created in a meeting, where each element is an object of type DytePollMessage.

The DytePollMessage class has the following properties:

  • id: Unique ID assigned to each poll.
  • question: Question of the poll.
  • anonymous: To hide the votes of each user even after completion. (false by default)
  • hideVotes: Hide votes until the voting is complete. (enabled if anonymous is enabled)
  • createdBy: Name of creator the poll.
  • options: Array of DytePollOption object, contains all the options to the poll question.

DytePollOption has the following properties:

  • text : Contains the option text.
  • votes : List of DytePollVote object, which contains info about voters of this option.
  • count : Int of number of votes given to this option.

DytePollVote has the following properties:

  • id : ID of the voter.
  • name : Name of the voter.

Listening to new polls in a meeting

To be able to receive new poll messages you need to implement a method onPollUpdates() method from callback DyteMeetingRoomEventsListener:

To get poll updates, listen to onPollUpdates() callback:


class MeetingRoomEventsListener with DyteMeetingRoomEventsListener {

...


void onPollUpdates({
required bool newPoll,
required List<DytePollMessage> pollMessages,
DytePollMessage? updatedPollMessage,
}) {
/// code to handle polls
}

...
}

You can subscribe to this events by addMeetingEventsListener method:


dyteClient.addMeetingEventsListener(
/// MeetingRoomEventsListener instance
)