PollModalOptions class

Configuration for the polling modal enabling real-time poll creation, voting, and results display.

  • member - Current user's name; used to check existing votes (prevent double-voting).
  • islevel - Privilege level ('2' = host, '1' = moderator, '0' = participant); host/moderator can create/end polls and view previous results.
  • polls - Array of completed Poll objects; only visible to host/moderator in "Previous Polls" tab.
  • poll - Active Poll object; displayed in "Current Poll" tab. null if no active poll.
  • handleCreatePoll - Override for handleCreatePoll; receives {poll, parameters}. Creates new poll, emits createPoll socket event.
  • handleEndPoll - Override for handleEndPoll; receives {pollId, parameters}. Ends active poll, emits endPoll socket event.
  • handleVotePoll - Override for handleVotePoll; receives {pollId, optionIndex, parameters}. Casts vote, emits votePoll socket event.
  • updateIsPollModalVisible - Callback to toggle modal visibility.
  • socket - Socket.IO client for emitting poll actions.
  • roomName - Session identifier for socket events.
  • showAlert - Optional ShowAlert callback for validation messages.
  • position - Modal placement via getModalPosition (e.g., 'topRight').
  • backgroundColor - Background color for modal container.
  • styles - Optional PollModalStyleOptions for advanced theming.
  • previousPollsHeader / createPollHeader / currentPollHeader / emptyPreviousPollsPlaceholder / emptyCurrentPollPlaceholder - Custom widgets for section headers and empty states.

Compatible with ModernPollModalOptions from the modern component.

Usage

  1. Modal displays three tabs (host/moderator): "Previous Polls", "New Poll", "Current Poll".
  2. Participants see "Current Poll" tab only.
  3. "New Poll" tab: dropdown for poll type (True/False, Yes/No, Custom), question input, custom options (for Custom type).
  4. "Current Poll" tab: displays question, options with vote counts/percentages; radio buttons for voting (disabled if already voted); "End Poll" button (host/moderator only).
  5. "Previous Polls" tab: scrollable list of completed polls with results (host/moderator only).
  6. Override via MediasfuUICustomOverrides.pollModal to inject analytics tracking, poll templates, or advanced voting types (ranked-choice, approval voting).

Constructors

PollModalOptions({required bool isPollModalVisible, required VoidCallback onClose, String position = 'topRight', Color backgroundColor = const Color(0xFFF5F5F5), required String member, required String islevel, required List<Poll> polls, Poll? poll, Socket? socket, required String roomName, ShowAlert? showAlert, required ValueChanged<bool> updateIsPollModalVisible, required HandleCreatePollType handleCreatePoll, required HandleEndPollType handleEndPoll, required HandleVotePollType handleVotePoll, PollModalStyleOptions? styles, Widget? previousPollsHeader, Widget? createPollHeader, Widget? currentPollHeader, Widget? emptyPreviousPollsPlaceholder, Widget? emptyCurrentPollPlaceholder, bool isDarkMode = false, bool enableGlassmorphism = false, ModalRenderMode renderMode = ModalRenderMode.modal})

Properties

backgroundColor Color
final
createPollHeader Widget?
final
currentPollHeader Widget?
final
emptyCurrentPollPlaceholder Widget?
final
emptyPreviousPollsPlaceholder Widget?
final
enableGlassmorphism bool
Enable glassmorphism effects for modern styling. Note: Pending modern implementation - placeholder for future glassmorphic UI.
final
handleCreatePoll HandleCreatePollType
final
handleEndPoll HandleEndPollType
final
handleVotePoll HandleVotePollType
final
hashCode int
The hash code for this object.
no setterinherited
isDarkMode bool
Dark mode toggle for modern styling. Note: Pending modern implementation - placeholder for future glassmorphic UI.
final
islevel String
final
isPollModalVisible bool
final
member String
final
onClose VoidCallback
final
poll Poll?
final
polls List<Poll>
final
position String
final
previousPollsHeader Widget?
final
renderMode ModalRenderMode
Render mode for the modal (modal, sidebar, or inline). When set to sidebar or inline, returns content without modal wrapper.
final
roomName String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showAlert ShowAlert?
final
socket → Socket?
final
styles PollModalStyleOptions?
final
updateIsPollModalVisible ValueChanged<bool>
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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