LMFeedPoll
LMFeedPoll
is a widget that displays a poll within a feed post. The widget provides customization options for styling the poll, handling errors, and responding to tap events.
The LMFeedPoll
widget is part of the likeminds_feed_flutter_ui
package. It is designed to be used within an LMFeedPostWidget
to display poll associated with a post.
Properties
attachmentMeta
(LMAttachmentMetaViewData
)Poll Data. This is required parameter.
rebuildPollWidget
(ValueNotifier<bool>?
)Used to rebuild the poll widget on user interaction. This is an optional parameter.
onCancel
(VoidCallback?
)A callback function that is invoked when user tap on cancel button. This is an optional parameter.
onEdit
(Function(LMAttachmentMetaViewData)?
)A callback function that is invoked when user tap on edit poll button. This is an optional parameter.
onEditVote
(Function(LMAttachmentMetaViewData)?
)A callback function that is invoked when user tap on edit vote button. This is an optional parameter.
style
(LMFeedPollStyle?
)The style configuration for the Poll. It allows customization of the poll's appearance and behavior. This is an optional parameter.
onOptionSelect
(void Function(LMPollOptionViewData)?
)A callback function that is invoked when user tap on any option. This is an optional parameter.
showSubmitButton
(bool
)A Boolean to show the submit button. This is an optional parameter with default value
false
showEditVoteButton
(bool
)A Boolean to show the edit vote button. This is an optional parameter with default value
false
showAddOptionButton
(bool
)A Boolean to show the edit vote button. This is an optional parameter with default value
false
isVoteEditing
(bool
)A Boolean to notify is vote editing. This is an optional parameter with default value
false
showTick
(bool Function(LMPollOptionViewData optionViewData)?
)A Boolean to show tick icon on option. This is an optional parameter.
timeLeft
(String?
)Indicates time left for the poll to end. This is an optional parameter.
onAddOptionSubmit
(void Function(String option)?
)A callback function that is invoked when a new option is added. This is an optional parameter.
onVoteClick
(Function(LMPollOptionViewData)?
)A callback function that is invoked when user tap on vote text. This is an optional parameter.
selectedOption
(List<String>
)List of selected option when submitting the poll votes. This is an optional parameter with default value
[]
onSubmit
(Function(List<String> selectedOption)?
)A callback function that is invoked when user tap submit button. This is an optional parameter.
onSubtextTap
(VoidCallback?
)A callback function that is invoked when user tap subtext. This is an optional parameter.
pollSelectionText
(String?
)Poll selection text. This is an optional parameter.
pollQuestionBuilder
(Widget Function(BuildContext)?
)Builder for the poll question widget. This is an optional parameter.
pollActionBuilder
(Widget Function(BuildContext)?
)Builder for the poll action widget. This is an optional parameter.
pollOptionBuilder
(Widget Function(BuildContext)?
)Builder for the poll option widget. This is an optional parameter.
pollSelectionTextBuilder
(Widget Function(BuildContext)?
)Builder for the poll selection text widget. This is an optional parameter.
addOptionButtonBuilder
(LMFeedButtonBuilder?
)Builder for the add option button. This is an optional parameter.
submitButtonBuilder
(LMFeedButtonBuilder?
)Builder for the submit button. This is an optional parameter.
subTextBuilder
(Widget Function(BuildContext)?
)Builder for the subtext. This is an optional parameter.
onSameOptionAdded
(VoidCallback?
)A callback function that is invoked when same option is added twice. This is an optional parameter.
isMultiChoicePoll
(bool?
)A Boolean to show if the poll is multi choice. This is an optional parameter.
Styling
The LMFeedPollStyle
class allows you to customize the appearance and behavior of the LMFeedPoll
widget.
Customization variables
Property | Type | Description | Required |
---|---|---|---|
pollQuestionStyle | TextStyle? | TextStyle for poll question text | |
pollQuestionExpandedText | String? | Expanded Text for poll question | |
pollInfoStyles | LMFeedTextStyle? | Text Style for poll info text | |
pollAnswerStyle | LMFeedTextStyle? | Text Style for poll answer text | |
timeStampStyle | LMFeedTextStyle? | Text Style for time stamp text | |
percentageStyle | LMFeedTextStyle? | Text Style for percentage text | |
editPollOptionsStyles | LMFeedTextStyle? | Text Style for edit poll options text | |
submitPollTextStyle | LMFeedTextStyle? | Text Style for submit poll text | |
submitPollButtonStyle | LMFeedButtonStyle? | LMFeedButtonStyle for submit poll button style | |
pollOptionStyle | LMFeedPollOptionStyle? | LMPollOptionStyle for poll option style |
You can create an instance of LMFeedPollStyle
and pass it to the LMFeedPoll
widget to customize its appearance and behavior.
The LMFeedPollOptionStyle
class allows you to customize the appearance and behavior of the LMFeedPollOption
widget.
Property | Type | Description | Required |
---|---|---|---|
pollOptionSelectedColor | Color? | Color for poll option selected color | |
pollOptionOtherColor | Color? | Color for poll option other color | |
pollOptionSelectedTickColor | Color? | Color for tick in poll option selected | |
pollOptionSelectedBorderColor | Color? | Color for border of selected poll option | |
pollOptionSelectedTextColor | Color? | Color for text color of selected poll option | |
pollOptionOtherTextColor | Color? | Color for text color of other poll option | |
votesCountStyles | LMFeedTextStyle? | Text Style for votes count text | |
pollOptionTextStyle | LMFeedTextStyle? | Text Style for poll option text | |
pollOptionDecoration | BoxDecoration? | BoxDecoration for poll option decoration |
Usage Example
LMFeedPoll(
attachmentMeta: attachmentMeta,
style: LMFeedPollStyle(
margin: const EdgeInsets.symmetric(
vertical: 8,
),
backgroundColor: Colors.white,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.grey,
),
),
pollOptionStyle: LMFeedPollOptionStyle(
pollOptionSelectedColor:
LikeMindsTheme.primaryColor.withOpacity(0.2),
pollOptionOtherColor:
const Color.fromRGBO(230, 235, 245, 1),
),
),
);
In this example, an LMFeedPoll
widget is created with the attachmentMeta
, with basic styles.