Giter Club home page Giter Club logo

polls's Introduction

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

polls's People

Contributors

aksharprasanna avatar deuque avatar piperstackist avatar samuelezedi avatar solveitproject avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

polls's Issues

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

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 ?

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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.