DynamicPolls class

A customizable widget for displaying and interacting with a poll.

Example usage:

DynamicPolls(
  title: 'What is your favorite color?',
  options: ['Red', 'Green', 'Blue'],
  allowReselection: true,
  showPercentages: true,
  startDate: DateTime.now(),
  endDate: DateTime.now().add(Duration(days: 1)),
  backgroundDecoration: BoxDecoration(
    color: Colors.white,
    borderRadius: BorderRadius.circular(10),
  ),
  votesText: 'Votes',
  createdBy: 'John Doe',
  userToVote: 'John Doe',
  private: false,
  loadingWidget: CircularProgressIndicator(),
  onOptionSelected: (index) {
}
)
Inheritance

Constructors

DynamicPolls({Key? key, required String title, required List<String> options, required DateTime startDate, required DateTime endDate, required dynamic onOptionSelected(int), int? totalVotes, int? id, bool showPercentages = true, num? maximumOptions = 20, Decoration? backgroundDecoration, bool allowReselection = false, double? heightBetweenTitleAndOptions = 10, String? votesText = 'Votes', String? createdBy, UserDataModel? userData, bool private = false, Widget? loadingWidget, StreamController<VoteData>? voteStream, Styles? allStyle, double? height, double? width, bool showTimer = false, ValueNotifier<VoteData>? voteNotifier, PollsLabels? pollsLabels})
Creates a new DynamicPolls widget.

Properties

allowReselection bool
Whether users can reselect an option after voting.
final
allStyle Styles?
The styles to apply to the poll.
final
backgroundDecoration Decoration?
The decoration applied to the background of the poll.
final
createdBy String?
The name of the user who created the poll.
final
endDate DateTime
The end date of the poll.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
The height of the poll widget.
final
heightBetweenTitleAndOptions double?
The height between the title and the options.
final
id int?
The ID of the poll.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadingWidget Widget?
The widget to display while the poll is loading.
final
maximumOptions num?
The maximum number of options allowed in the poll.
final
onOptionSelected → dynamic Function(int)
A callback function that is called when an option is selected.
final
options List<String>
The list of options for the poll.
final
pollsLabels PollsLabels?
The labels for the poll.
final
private bool
Whether the poll is private.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showPercentages bool
Whether to display the percentage of votes for each option.
final
showTimer bool
Whether to show a timer for the poll duration.
latefinal
startDate DateTime
The start date of the poll.
final
title String
The title of the poll.
final
totalVotes int?
The total number of votes cast in the poll.
getter/setter pair
userData UserDataModel?
The name of the user who is allowed to vote.
final
voteNotifier ValueNotifier<VoteData>?
A notifier for handling vote updates.
final
votesText String?
The text displayed next to the vote count.
final
voteStream StreamController<VoteData>?
A stream controller for handling vote updates.
final
width double?
The width of the poll widget.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<DynamicPolls>
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, int wrapWidth = 65}) 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

Static Methods

polls({int? id, bool allowReselection = false, required String title, required List<String> options, bool private = false, required dynamic onOptionSelected(int), int? totalVotes, num? maximumOptions = 20, Decoration? backgroundDecoration, double? heightBetweenTitleAndOptions = 10, double? heightBetweenOptions = 12, String? votesText = 'Votes', String? createdBy, UserDataModel? userData, Widget? loadingWidget, Styles? allStyle, StreamController<VoteData>? voteStream, ValueNotifier<VoteData>? voteNotifier, double? height, double? width, bool showPercentages = true, PollsLabels? pollsLabels}) Widget
radioBottomPolls({int? id, required bool allowReselection, required String title, required List<String> options, Decoration? backgroundDecoration, bool showPercentages = true, double? heightBetweenTitleAndOptions = 10, String? votesText = 'Votes', String? createdBy, UserDataModel? userData, bool private = false, Widget? loadingWidget, required dynamic onOptionSelected(int), Styles? allStyle, num? maximumOptions = 20, StreamController<VoteData>? voteStream, ValueNotifier<VoteData>? voteNotifier, double? height, double? width, double? heightProgress = 15, Color? progressColor = Colors.blue, Color? backgroundProgressColor = const Color.fromRGBO(224, 224, 224, 1), int? totalVotes, double? heightBetweenOptions = 10, PollsLabels? pollsLabels}) Widget
viewOnlyPollWidget({bool allowReselection = false, required String title, required List<String> options, required Map<int, int> votes, required int totalVotes, bool showPercentages = true, required DateTime startDate, required DateTime endDate, double? heightBetweenTitleAndOptions = 10, double? heightBetweenOptions = 12, String? votesText = 'Votes', TextStyle? votesTextStyle, Widget? metaWidget, String? createdBy, String? userToVote, double? pollOptionsHeight = 48, double? pollOptionsWidth, BorderRadius? pollOptionsBorderRadius, Color? pollOptionsFillColor = Colors.white, Color? pollOptionsSplashColor = Colors.grey, BoxBorder? pollOptionsBorder, BoxBorder? votedPollOptionsBorder, Radius? votedPollOptionsRadius, Color? votedBackgroundColor = const Color(0xffEEF0EB), Color? votedProgressColor = const Color(0xff84D2F6), Color? leadingVotedProgessColor = const Color(0xff0496FF), Color? voteInProgressColor = const Color(0xffEEF0EB), Widget? votedCheckmark, TextStyle? votedPercentageTextStyle, int votedAnimationDuration = 1000, Widget? loadingWidget}) Widget
Creates a view-only poll widget.