polls 패키지는 Flutter 위젯으로 트위터 투표 인터페이스를 복제하여 앱 내에서 상호작용 가능한 투표 시스템을 만들 수 있게 해줍니다. 실시간 투표 및 시각적 피드백을 지원해 소셜 미디어 기능에 이상적입니다. 개발자는 데이터 소스를 쉽게 통합할 수 있으며, 최소한의 설정만으로도 사용 가능합니다. 이 패키지는 단순성과 미학에 중점을 두며, 사용자 의견을 수집하는 깔끔하고 직관적인 방법을 제공합니다. 기존의 Flutter 프로젝트에 원활하게 통합되도록 설계되었습니다.
Polls(
children: [
// This cannot be less than 2, else will throw an exceptionPolls.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