Skip to main content

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.

LMFeedImage

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

PropertyTypeDescriptionRequired
pollQuestionStyleTextStyle?TextStyle for poll question text
pollQuestionExpandedTextString?Expanded Text for poll question
pollInfoStylesLMFeedTextStyle?Text Style for poll info text
pollAnswerStyleLMFeedTextStyle?Text Style for poll answer text
timeStampStyleLMFeedTextStyle?Text Style for time stamp text
percentageStyleLMFeedTextStyle?Text Style for percentage text
editPollOptionsStylesLMFeedTextStyle?Text Style for edit poll options text
submitPollTextStyleLMFeedTextStyle?Text Style for submit poll text
submitPollButtonStyleLMFeedButtonStyle?LMFeedButtonStyle for submit poll button style
pollOptionStyleLMFeedPollOptionStyle?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.

PropertyTypeDescriptionRequired
pollOptionSelectedColorColor?Color for poll option selected color
pollOptionOtherColorColor?Color for poll option other color
pollOptionSelectedTickColorColor?Color for tick in poll option selected
pollOptionSelectedBorderColorColor?Color for border of selected poll option
pollOptionSelectedTextColorColor?Color for text color of selected poll option
pollOptionOtherTextColorColor?Color for text color of other poll option
votesCountStylesLMFeedTextStyle?Text Style for votes count text
pollOptionTextStyleLMFeedTextStyle?Text Style for poll option text
pollOptionDecorationBoxDecoration?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.