PollModal class

PollModal is a modal widget that provides an interface for creating, viewing, and managing polls in a real-time environment with socket-based communication.

This widget allows users to:

  • View previous polls and their results (for authorized users only).
  • Create a new poll with various types (e.g., True/False, Yes/No, or Custom).
  • View and participate in the currently active poll by casting votes.
  • End the current poll if the user has the appropriate permissions.

Parameters:

  • PollModalOptions (options): Configuration options for the modal, including:
    • isPollModalVisible: Whether the modal is visible.
    • onClose: Callback when the modal is closed.
    • position: Position of the modal on the screen (e.g., 'topRight').
    • backgroundColor: Background color of the modal.
    • member: Member identifier for tracking user interactions.
    • islevel: Authorization level for access control.
    • polls: List of available polls for viewing past results.
    • poll: The currently active poll.
    • socket: Socket instance for real-time communication.
    • roomName: Name of the room associated with the polls.
    • showAlert: Function to show alerts, if any.
    • updateIsPollModalVisible: Callback to update the visibility of the poll modal.
    • handleCreatePoll: Function to handle poll creation.
    • handleEndPoll: Function to handle ending a poll.
    • handleVotePoll: Function to handle voting on a poll.

Example Usage:

PollModal(
  options: PollModalOptions(
    isPollModalVisible: true,
    onClose: () => print("Modal closed"),
    position: 'topRight',
    member: 'user123',
    islevel: '2',
    polls: [
      Poll(id: '1', question: 'Example Question?', options: ['Yes', 'No'], votes: [5, 3], status: 'active', voters: {} )
    ],
    poll: Poll(id: '2', question: 'Current Active Poll?', options: ['Option 1', 'Option 2'], votes: [0, 0], status: 'active', voters: {}),
    socket: io.Socket(),
    roomName: 'room_1',
    updateIsPollModalVisible: (visible) => print("Poll modal visibility: $visible"),
    handleCreatePoll: (options) => print("Poll created: ${options.poll}"),
    handleEndPoll: (options) => print("Poll ended: ${options.pollId}"),
    handleVotePoll: (options) => print("Vote cast on poll: ${options.pollId}"),
  ),
);

This example initializes the PollModal with mock data and handlers, enabling the user to view and interact with polls in the UI.

Inheritance

Constructors

PollModal({Key? key, required PollModalOptions options})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
options PollModalOptions
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _PollModalState
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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