A flutter package for voting processes e.g elections.

Overview

Polls

pub package

GitHub

ScreenShots

Voting Not Voted Yet Voted

Usage

Basic:

import 'package:polls/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: this.user,
        creatorID: this.creator,
        voteData: usersWhoVoted,
        userChoice: usersWhoVoted[this.user],
        onVoteBackgroundColor: Colors.blue,
        leadingBackgroundColor: Colors.blue,
        backgroundColor: Colors.white,
        onVote: (choice) {

            setState(() {
              this.usersWhoVoted[this.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 I made this plugin

Apparently, I have built 2 apps that required user voting processes, twice I had to implement same code on different apps. I also had to share the code with a friend, well I thought it would not be a bad idea to create a package off it, cause at this time there was no polls widget package on pub.dev

kindly follow on github

github

Kindly follow me on

twitter medium instagram

Comments
  • Post Voting view rendered incorrectly

    Post Voting view rendered incorrectly

    I tried running the code given in the example. I noticed that the value of for an option, even though updated is not rendered in the post voting view for some reason. So, our vote is not taken into account.

    For instance, in the attached screenshot, I have voted for Mecca which is still at 0. The values set for options prior to voting is taken and not updated after voting.

    WhatsApp Image 2020-07-11 at 12 06 29 AM

    opened by AksharPrasanna 5
  • Request for adding some more details in the package documentation

    Request for adding some more details in the package documentation

    Respected Sir/Madam, Can you add some more details in the documentation regarding the usage and various properties of the package and some examples of how to use this package to create dynamic polls? Thank You,

    opened by Coder-19 2
  • Fix for incorrect post voting view render issue

    Fix for incorrect post voting view render issue

    Hello Samuel,

    In continuation to - Issue https://github.com/samuelezedi/polls/issues/1 I had been using 0.1.8 from the start. So I tried to dig deeper to see what was causing my issue. I kind of figured out what the issue was. So the values initialised in the initState does not get re-initialised upon triggering setState. I am not entirely sure why this is happening. I am pretty new to flutter myself.

    I had hit this issue earlier in one of my other codes. I sort of solved it then by re-initialising the required variables before using it in the required widget. I forked your repository and tried doing the same thing. And it worked. It's just 4 lines of code.

    Please do review this 😄

    opened by AksharPrasanna 2
  • I'd like to change viewType

    I'd like to change viewType

    Hello, samuelezedi !

    I 'd like to change viewType to set vote's deadline. So, I tried to add viewType option But 'optionsUndefined name 'viewType' ' error occured.. I don't know how to disable voteOptions..

    my polls version is 1.0.1

    opened by pdw624 1
  • Create poll options from list cause TypeError

    Create poll options from list cause TypeError

    What behavior was I expecting?

    To create a list of poll option from a list.

    What actually happened?

    Screenshot 2021-10-04 at 19 49 05

    How can I reproduce it?

    Widget build(BuildContext context) {
        List<Player> players = widget.session.team.players;
        return Container(
          child: Polls(
            children: [
              players
                  .map((i) => Polls.options(title: '${i.pseudo}', value: option1))
                  .toList(),
            ],
            question: Text('how old are you?'),
            currentUser: this.user,
            creatorID: this.creator,
            voteData: usersWhoVoted,
            userChoice: usersWhoVoted[this.user],
            onVoteBackgroundColor: Colors.blue,
            leadingBackgroundColor: Colors.blue,
            backgroundColor: Colors.white,
            onVote: (choice) {
              print(choice);
            },
          ),
        );
      }
    

    Player is a normal dart class with a field pseudo.

    Question :

    His it possible to create polls options from a map ?

    opened by GaetanFauconnier85 1
  • LateInitializationError: Field 'leadingPollStyle' has not been initialized.

    LateInitializationError: Field 'leadingPollStyle' has not been initialized.

    Hey Guys, just came across your package today and was playing around with it. I was trying to set a custom pollStyle and leadingPollStyle, but they throw: LateInitializationError: Field 'leadingPollStyle' has not been initialized. I've looked at your example but still can't figure out how this is supposed to be used.

    opened by m-j-g 0
Owner
Samuel Ezedi
Futurist, Music Junkie and Software Engineer
Samuel Ezedi
A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Muhammad Hamza 21 Jan 1, 2023
Flutter 2.0 (Null safety) Basic, Dynamic & Silver style Staggered Grid views made using flutter staggered grid view package. 🦺

Staggered Grid View Developement Stack Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Nakshatra Singh 9 Oct 28, 2022
A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.

system_tray A Flutter package that that enables support for system tray menu for desktop flutter apps. on Windows, macOS and Linux. Features: - Modify

AnTler 140 Dec 30, 2022
A Flutter package that makes it easy to customize and work with your Flutter desktop app window.

bitsdojo_window A Flutter package that makes it easy to customize and work with your Flutter desktop app window on Windows, macOS and Linux. Watch the

Bits Dojo 606 Dec 27, 2022
In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google Admob Package.

?? Monetizing Flutter apps with Google AdMob ?? In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google A

SnippetCoder 14 Nov 30, 2022
Firebase Cloud Messaging (FCM) Flutter package.

Firebase Messaging Plugin for Flutter A Flutter plugin to use the Firebase Cloud Messaging API. To learn more about Firebase Cloud Messaging, please v

Wael Alhalabi 12 Dec 10, 2022
A Flutter project that implemented getx package and firebase services.

Get X Firebase A Flutter Package that implemented firebase services with getx package. It's free, open source, complete, rapid development package for

Faisal Ramdan 19 Nov 26, 2022
A Flutter package for getting app feedback from users.

App Feedback A Flutter package for getting app feedback from users. Other Flutter packages Name Stars Pub Filter List Empty widget Add Thumbnail Count

Sonu Sharma 11 Nov 13, 2022
A Flutter package for show custom in-app notification.

?? in_app_notification A Flutter package to show custom in-app notification with any Widgets. ✍️ Usage Import it. dependencies: in_app_notificatio

CBcloud 18 Oct 27, 2022
A Flutter package for working with piano keys and sheet music

Piano A Flutter package that provides: logic for working with musical notes, clefs and octaves; a widget that can render notes on a clef; an interacti

Craig McMahon 32 Jan 5, 2023
A Flutter package to simplify firebase authentication.

firebase_authentication A Flutter package to simplify firebase authentication. Development State This is in a very, very early stage. It's a draft bas

Daniele Cambi 32 Apr 24, 2022
A Flutter package for building custom skeleton widgets to mimic the page's layout while loading.

Skeletons A Flutter package for building custom skeleton widgets to mimic the page's layout while loading. Examples Items ListView (Default) ListView

Moh Badjah 46 Dec 17, 2022
A Flutter package to manage feature flagging.

feature_flags This package simply allows you to activate dynamically functionnalities of your app. Usage Setup Wrap your app's widget in a Features wi

Aloïs Deniel 20 Oct 11, 2022
An flutter package to use DevIcons https://devicon.dev/

dev_icons This flutter package allows you to use all the Dev Icons. You can view the icons catalog on devicon.dev Installation In the dependencies: se

Festus Olusegun 22 Oct 9, 2022
A set of real world timelines to showcase the use of timeline_tile package, built with Flutter.

beatiful_timelines Beautiful timelines built with Flutter and timeline_tile. Current examples: Timeline Showcase Football Timeline Activity Timeline S

null 233 Dec 21, 2022
A Dart/Flutter package to register/query/remove URI Schemes without hassle.

protocol_registry Register/query/remove URI Schemes without hassle. Available for Windows and Linux. Installation flutter pub add protocol_registry Us

ZYROUGE 10 Oct 25, 2022
Flutter network manager package.

Features With Network Manager, you can now easily manage your internet requests, send and receive data. Usage Set Base URL Settings Base URL -> Networ

Sercan KAYA 14 Dec 4, 2022
A Flutter package which implements a ConvexAppBar to show a convex tab in the bottom bar. Theming supported.

English | 简体中文 The official BottomAppBar can only display a notch FAB with an app bar, and sometimes we need a convex FAB. BottomAppBar and NotchShape

Thinking in code 647 Dec 28, 2022
A Flutter package with custom implementation of Drawer

Flutter Zoom Drawer A Flutter package with custom implementation of the Side Menu (Drawer) Getting Started To start using this package, add flutter_zo

null 335 Dec 22, 2022