better_polls 1.0.8 copy "better_polls: ^1.0.8" to clipboard
better_polls: ^1.0.8 copied to clipboard

A better flutter widget for polls, this immitates the twitter polls system, all you need do is connect you data to the polls, it allows voting and visualization.

Polls #

pub package

GitHub

ScreenShots #

Voting Not Voted Yet Voted

Usage #

Basic:

import 'package:better_polls/better_polls.dart';
copied to clipboard
Polls(
    children: [
      // This cannot be less than 2, else will throw an exception
      Polls.options(title: 'Cairo', value: option1),
      Polls.options(title: 'Mecca', value: option2),
      Polls.options(title: 'Denmark', value: option3),
      Polls.options(title: 'Maldives', value: option4),
    ],
    optionBarRadius: 24,
    borderWidth: 1,
    optionHeight: 40,
    question: const Padding(
      padding: EdgeInsets.only(bottom: 16.0),
      child: Text('What is your favorite place?'),
    ),
    currentUser: user,
    creatorID: creator,
    voteData: usersWhoVoted,
    userChoice: usersWhoVoted[user],
    onVoteBorderColor: Colors.deepPurple,
    voteCastedBorderColor: Colors.transparent,
    onVoteBackgroundColor: Colors.blue,
    leadingBackgroundColor: Colors.lightGreen,
    backgroundColor: Colors.white,
    onVote: (choice) {
      setState(() {
        usersWhoVoted[user] = choice;
      });
      if (choice == 1) {
        setState(() {
          option1 += 1.0;
        });
      }
      if (choice == 2) {
        setState(() {
          option2 += 1.0;
        });
      }
      if (choice == 3) {
        setState(() {
          option3 += 1.0;
        });
      }
      if (choice == 4) {
        setState(() {
          option4 += 1.0;
        });
      }
    },
  );
copied to clipboard

Poll View type #

Polls(
  viewType: PollsType.creator
);
copied to clipboard
Polls(
viewType: PollsType.voter
);
copied to clipboard
Polls(
viewType: PollsType.readOnly
);
copied to clipboard

Why we forked the original polls package #

We initially forked the package to update the package for Flutter 3, after the orignal package was not updated for months. After diving into the code, we noticed many design issues and it gave us even more of a reason to fork the package. Our version now includes various improvements on structure and overall code cleanliness. Some of the enhancements, include reduction in line count from 1500 to 500, remove redundant code, add ability to add unlimited polls, and overall maintainability improvements.

8
likes
140
points
85
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.02 - 2025.04.16

A better flutter widget for polls, this immitates the twitter polls system, all you need do is connect you data to the polls, it allows voting and visualization.

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

collection, flutter, percent_indicator

More

Packages that depend on better_polls