Skip to content

Commit 32eaa7b

Browse files
Version 0.2.2 Released
1 parent dfb2a78 commit 32eaa7b

File tree

7 files changed

+231
-144
lines changed

7 files changed

+231
-144
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [0.2.2] - Jun 23 2022.
2+
* Fixes:
3+
* Showed duration value when autoStart is false.
4+
* If initialDuration is given, then timer doesn't starts. It hangs.
5+
6+
* Features:
7+
* Added parameters (isStarted, isPaused, isResumed) in CountDownController to get the current status of Countdown Timer.
8+
* Added **reset** method in CountDownController to reset the Countdown Timer.
9+
* Added Optional Parameter ValueChanged<String> named **onChange** which will execute when the Countdown Changes.
10+
111
## [0.2.1] - Mar 13 2022.
212
* Updated package to latest Flutter version.
313

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To use this plugin, add `circular_countdown_timer` as a [dependency in your pubs
99
## Features
1010
* Forward Countdown Timer.
1111
* Reverse Countdown Timer.
12-
* Start, Pause, Resume and Restart Timer.
12+
* Start, Pause, Resume, Restart and Reset Timer.
1313

1414
## Usage
1515

@@ -36,10 +36,13 @@ CircularCountDownTimer(
3636
isTimerTextShown: true,
3737
autoStart: false,
3838
onStart: () {
39-
debugPrint('Countdown Started');
39+
debugPrint('Countdown Started');
4040
},
4141
onComplete: () {
42-
debugPrint('Countdown Ended');
42+
debugPrint('Countdown Ended');
43+
},
44+
onChange: (String timeStamp) {
45+
debugPrint('Countdown Changed $timeStamp');
4346
},
4447
);
4548
```
@@ -69,11 +72,15 @@ CircularCountDownTimer(
6972
|`autoStart`|`bool`|true|*Handles the timer start.*|
7073
|`onStart`|`VoidCallback`|null|*This Callback will execute when the Countdown Starts.*|
7174
|`onComplete`|`VoidCallback`|null|*This Callback will execute when the Countdown Ends.*|
75+
|`onChange`|`ValueChanged<String>`|null|*This Callback will execute when the Countdown Changes.*|
7276

7377
## Demo
7478

7579
![demo](https://user-images.githubusercontent.com/30389103/107875872-235f9e80-6ee4-11eb-9fd5-4e57d8f1cb00.gif)
7680

7781
## Youtube
7882

79-
[Bekar Programmer](https://www.youtube.com/channel/UCxjtmtkMX_uJBfqwZpa-m9A)
83+
[Bekar Programmer](https://www.youtube.com/channel/UCxjtmtkMX_uJBfqwZpa-m9A)
84+
85+
86+
<a href="https://www.buymeacoffee.com/usamasiddiqui" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

example/example.dart

Lines changed: 87 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MyHomePage extends StatefulWidget {
2525
final String? title;
2626

2727
@override
28-
_MyHomePageState createState() => _MyHomePageState();
28+
State<MyHomePage> createState() => _MyHomePageState();
2929
}
3030

3131
class _MyHomePageState extends State<MyHomePage> {
@@ -39,117 +39,135 @@ class _MyHomePageState extends State<MyHomePage> {
3939
title: Text(widget.title!),
4040
),
4141
body: Center(
42-
child: CircularCountDownTimer(
43-
// Countdown duration in Seconds.
44-
duration: _duration,
42+
child: CircularCountDownTimer(
43+
// Countdown duration in Seconds.
44+
duration: _duration,
4545

46-
// Countdown initial elapsed Duration in Seconds.
47-
initialDuration: 0,
46+
// Countdown initial elapsed Duration in Seconds.
47+
initialDuration: 0,
4848

49-
// Controls (i.e Start, Pause, Resume, Restart) the Countdown Timer.
50-
controller: _controller,
49+
// Controls (i.e Start, Pause, Resume, Restart) the Countdown Timer.
50+
controller: _controller,
5151

52-
// Width of the Countdown Widget.
53-
width: MediaQuery.of(context).size.width / 2,
52+
// Width of the Countdown Widget.
53+
width: MediaQuery.of(context).size.width / 2,
5454

55-
// Height of the Countdown Widget.
56-
height: MediaQuery.of(context).size.height / 2,
55+
// Height of the Countdown Widget.
56+
height: MediaQuery.of(context).size.height / 2,
5757

58-
// Ring Color for Countdown Widget.
59-
ringColor: Colors.grey[300]!,
58+
// Ring Color for Countdown Widget.
59+
ringColor: Colors.grey[300]!,
6060

61-
// Ring Gradient for Countdown Widget.
62-
ringGradient: null,
61+
// Ring Gradient for Countdown Widget.
62+
ringGradient: null,
6363

64-
// Filling Color for Countdown Widget.
65-
fillColor: Colors.purpleAccent[100]!,
64+
// Filling Color for Countdown Widget.
65+
fillColor: Colors.purpleAccent[100]!,
6666

67-
// Filling Gradient for Countdown Widget.
68-
fillGradient: null,
67+
// Filling Gradient for Countdown Widget.
68+
fillGradient: null,
6969

70-
// Background Color for Countdown Widget.
71-
backgroundColor: Colors.purple[500],
70+
// Background Color for Countdown Widget.
71+
backgroundColor: Colors.purple[500],
7272

73-
// Background Gradient for Countdown Widget.
74-
backgroundGradient: null,
73+
// Background Gradient for Countdown Widget.
74+
backgroundGradient: null,
7575

76-
// Border Thickness of the Countdown Ring.
77-
strokeWidth: 20.0,
76+
// Border Thickness of the Countdown Ring.
77+
strokeWidth: 20.0,
7878

79-
// Begin and end contours with a flat edge and no extension.
80-
strokeCap: StrokeCap.round,
79+
// Begin and end contours with a flat edge and no extension.
80+
strokeCap: StrokeCap.round,
8181

82-
// Text Style for Countdown Text.
83-
textStyle: const TextStyle(
84-
fontSize: 33.0,
85-
color: Colors.white,
86-
fontWeight: FontWeight.bold,
87-
),
82+
// Text Style for Countdown Text.
83+
textStyle: const TextStyle(
84+
fontSize: 33.0,
85+
color: Colors.white,
86+
fontWeight: FontWeight.bold,
87+
),
8888

89-
// Format for the Countdown Text.
90-
textFormat: CountdownTextFormat.S,
89+
// Format for the Countdown Text.
90+
textFormat: CountdownTextFormat.S,
9191

92-
// Handles Countdown Timer (true for Reverse Countdown (max to 0), false for Forward Countdown (0 to max)).
93-
isReverse: false,
92+
// Handles Countdown Timer (true for Reverse Countdown (max to 0), false for Forward Countdown (0 to max)).
93+
isReverse: false,
9494

95-
// Handles Animation Direction (true for Reverse Animation, false for Forward Animation).
96-
isReverseAnimation: false,
95+
// Handles Animation Direction (true for Reverse Animation, false for Forward Animation).
96+
isReverseAnimation: false,
9797

98-
// Handles visibility of the Countdown Text.
99-
isTimerTextShown: true,
98+
// Handles visibility of the Countdown Text.
99+
isTimerTextShown: true,
100100

101-
// Handles the timer start.
102-
autoStart: false,
101+
// Handles the timer start.
102+
autoStart: false,
103103

104-
// This Callback will execute when the Countdown Starts.
105-
onStart: () {
106-
// Here, do whatever you want
107-
debugPrint('Countdown Started');
108-
},
104+
// This Callback will execute when the Countdown Starts.
105+
onStart: () {
106+
// Here, do whatever you want
107+
debugPrint('Countdown Started');
108+
},
109109

110-
// This Callback will execute when the Countdown Ends.
111-
onComplete: () {
112-
// Here, do whatever you want
113-
debugPrint('Countdown Ended');
114-
},
115-
)),
110+
// This Callback will execute when the Countdown Ends.
111+
onComplete: () {
112+
// Here, do whatever you want
113+
debugPrint('Countdown Ended');
114+
},
115+
116+
// This Callback will execute when the Countdown Changes.
117+
onChange: (String timeStamp) {
118+
// Here, do whatever you want
119+
debugPrint('Countdown Changed $timeStamp');
120+
},
121+
),
122+
),
116123
floatingActionButton: Row(
117124
mainAxisAlignment: MainAxisAlignment.center,
118125
children: [
119126
const SizedBox(
120127
width: 30,
121128
),
122-
_button(title: "Start", onPressed: () => _controller.start()),
129+
_button(
130+
title: "Start",
131+
onPressed: () => _controller.start(),
132+
),
123133
const SizedBox(
124134
width: 10,
125135
),
126-
_button(title: "Pause", onPressed: () => _controller.pause()),
136+
_button(
137+
title: "Pause",
138+
onPressed: () => _controller.pause(),
139+
),
127140
const SizedBox(
128141
width: 10,
129142
),
130-
_button(title: "Resume", onPressed: () => _controller.resume()),
143+
_button(
144+
title: "Resume",
145+
onPressed: () => _controller.resume(),
146+
),
131147
const SizedBox(
132148
width: 10,
133149
),
134150
_button(
135-
title: "Restart",
136-
onPressed: () => _controller.restart(duration: _duration))
151+
title: "Restart",
152+
onPressed: () => _controller.restart(duration: _duration),
153+
),
137154
],
138155
),
139156
);
140157
}
141158

142159
Widget _button({required String title, VoidCallback? onPressed}) {
143160
return Expanded(
144-
child: ElevatedButton(
145-
child: Text(
146-
title,
147-
style: const TextStyle(color: Colors.white),
148-
),
149-
style: ButtonStyle(
150-
backgroundColor: MaterialStateProperty.all(Colors.purple),
161+
child: ElevatedButton(
162+
style: ButtonStyle(
163+
backgroundColor: MaterialStateProperty.all(Colors.purple),
164+
),
165+
onPressed: onPressed,
166+
child: Text(
167+
title,
168+
style: const TextStyle(color: Colors.white),
169+
),
151170
),
152-
onPressed: onPressed,
153-
));
171+
);
154172
}
155173
}

0 commit comments

Comments
 (0)