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';
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;
        });
      }
    },
  );

Poll View type #

Polls(
  viewType: PollsType.creator
);
Polls(
viewType: PollsType.voter
);
Polls(
viewType: PollsType.readOnly
);

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.

6
likes
130
pub points
76%
popularity

Publisher

unverified uploader

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)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

collection, flutter, percent_indicator

More

Packages that depend on better_polls