Skip to content

Instantly share code, notes, and snippets.

@Arpit980jai

Arpit980jai/DART Secret

Last active August 6, 2021 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arpit980jai/1e1c3454f49abc473970754f2ac43b50 to your computer and use it in GitHub Desktop.
Save Arpit980jai/1e1c3454f49abc473970754f2ac43b50 to your computer and use it in GitHub Desktop.
Circular Countdown TIMER
import 'dart:async';
import 'dart:convert';
import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:circular_countdown_timer/circular_countdown_timer.dart';
import 'package:flash_chat/components/button.dart';
import 'package:flash_chat/screens/promotersDetails.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class ViewPromoters extends StatefulWidget {
final String a_id,s_id;
ViewPromoters({Key key, @required this.a_id,@required this.s_id}) : super(key: key);
@override
_ViewPromotersState createState() => _ViewPromotersState(a_id,s_id);
}
class _ViewPromotersState extends State<ViewPromoters> {
CountDownController _controller = CountDownController(); //cIRCULAR cOUNTDOWN tIMER
String p_id,p_name;
Map mapResponse;
List listResponse;
String a_id,s_id;
_ViewPromotersState(this.a_id,this.s_id);
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width * 0.6;
return Scaffold(
appBar: AppBar(
// App Bar
title: Text(
"Promoters Detail",
style: TextStyle(color: Colors.white),
),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.notifications_active,
color: Colors.white,
),
onPressed: () {
Notify();
},
)
],
elevation: 5,
backgroundColor: Colors.green,
),
// Main List View With Builder
body: ListView.builder(
itemCount: 3,
itemBuilder: (context, index) {
return Card(
color: Colors.white,
elevation: 5,
child: Column(
children: [ // hERE IS THE FUNCTION
CircularCountDownTimer(
width: MediaQuery.of(context).size.width / 6,
height: MediaQuery.of(context).size.width / 6,
duration: 120,
fillColor: Colors.green,
ringColor: Colors.white,
controller: _controller,
backgroundColor: Colors.white54,
strokeWidth: 10.0,
strokeCap: StrokeCap.round,
isTimerTextShown: true,
isReverse: false,
onComplete: () {
Notify();
},
textStyle: TextStyle(fontSize: 20.0, color: Colors.black),
),
Row(
children: <Widget>[
CircleAvatar(
radius: 60,
backgroundImage: AssetImage(imgList[index]),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: listResponse == null
? Container()
: Text(
listResponse[index]['name'].toString(),
style: TextStyle(
color: Colors.grey.shade500,
fontSize: 20.0,
fontWeight: FontWeight.w400,
),
),
),
SizedBox(
height: 10,
),
Container(
width: width,
child: Row(
children: [
Icon(
Icons.add_task_sharp,
color: Colors.grey[500],
size: 20.0,
),
SizedBox(
width: 7,
),
Text(
descList[index],
maxLines: 3,
style: TextStyle(
fontSize: 15,
color: Colors.grey[500],
fontWeight: FontWeight.w500),
),
],
),
),
Container(
width: width,
child: Row(
children: [
Icon(
Icons.add_photo_alternate_outlined,
color: Colors.grey[500],
size: 20.0,
),
SizedBox(
width: 7,
),
Text(
selfieList[index],
maxLines: 3,
style: TextStyle(
fontSize: 15,
color: Colors.grey[500],
fontWeight: FontWeight.w500),
),
],
),
),
Container(
width: width,
child: Row(
children: [
Icon(
Icons.dashboard_customize,
color: Colors.grey[500],
size: 20.0,
),
SizedBox(
width: 7,
),
Text(
dataList[index],
maxLines: 3,
style: TextStyle(
fontSize: 15,
color: Colors.grey[500],
fontWeight: FontWeight.w500),
),
],
),
),
Container(
width: width,
child: Row(
children: [
Icon(
Icons.assignment_ind_sharp,
color: Colors.grey[500],
size: 20.0,
),
SizedBox(
width: 7,
),
Text(
timeList[index],
maxLines: 3,
style: TextStyle(
fontSize: 15,
color: Colors.grey[500],
fontWeight: FontWeight.w500),
),
],
),
),
],
),
)
],
),
],
),
),
);
},
);
}
}
void Notify() async {
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: 1,
channelKey: 'key1',
title: 'This is Notification',
body: 'T His is body of Notify'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment