Skip to content

A flutter package for voting processes e.g elections.

License

Notifications You must be signed in to change notification settings

tjcampanella/better_polls

 
 

Repository files navigation

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: 'Mogadishu', value: option4),
        ],
        question: Text('What is the capital of Egypt'),
        currentUser: user,
        creatorID: creator,
        voteData: usersWhoVoted,
        userChoice: usersWhoVoted[user],
        onVoteBackgroundColor: Colors.blue,
        leadingBackgroundColor: Colors.blue,
        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.

About

A flutter package for voting processes e.g elections.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 38.9%
  • C++ 33.2%
  • CMake 16.2%
  • HTML 7.7%
  • Shell 1.5%
  • C 1.4%
  • Other 1.1%