import 'package:flutter/material.dart';
import 'package:flutter_polls/flutter_polls.dart';
class PollSection extends StatelessWidget {
const PollSection({super.key});
@OverRide
Widget build(BuildContext context) {
return DecoratedBox(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
color: Colors.black,
),
// height: 300,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.024, 32, MediaQuery.of(context).size.width * 0.024, 16),
child: Row(
children: [
Text(
"Guild's Poll",
),
],
),
),
const Padding(
padding: EdgeInsets.fromLTRB(16, 0, 16, 16),
child: CommunityPollBox(),
),
const SizedBox(height: 8,),
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: Expanded(
child: ElevatedButton(
child: Text(
'CREATE NEW POLL +',
),
onPressed: () {},
),
),
),
],
),
);
}
}
class CommunityPollBox extends StatelessWidget {
const CommunityPollBox({super.key});
@OverRide
Widget build(BuildContext context) {
return FlutterPolls(
pollId: '1',
onVoted: (PollOption pollOption, int newTotalVotes) async {
await Future.delayed(const Duration(seconds: 1));
/// If HTTP status is success, return true else false
return true;
},
pollOptionsSplashColor: Colors.green,
votedProgressColor: Colors.green,
pollOptionsFillColor: Colors.white,
votedBackgroundColor: Colors.grey,
votesTextStyle: TextStyle(color: $COLOR.GREEN, fontSize: 12),
votedCheckmark: const Icon(
Icons.check_circle,
color: Colors.black,
),
pollTitle: Align(
alignment: Alignment.centerLeft,
child: AutoSizeText(
'Who would win?',
style: TextStyle(color: $COLOR.WHITE, fontSize: 12),
),
),
pollOptions: [
PollOption(title: const Text('Zues'), votes: 60),
PollOption(title: const Text('Poseidon'), votes: 40),
],
metaWidget: Row(
children: const [
SizedBox(width: 6),
Text(
' | ',
style: TextStyle(
fontSize: 12,
color: Colors.green,
),
),
SizedBox(
width: 6,
),
Text(
'2 weeks left',
style: TextStyle(
fontSize: 12,
color: Colors.white,
),
),
],
),
);
}
}`
plz just ingore my removal of custom text styles. it is working properly on debug mode but not in prod.