A customizable countdown timer for Flutter apps. The SimpleTimerCountDown
widget allows you to easily implement countdown functionality with flexible intervals, callbacks, and custom UI rendering.
- Customizable Duration and Interval: Specify the total countdown time and update intervals.
- Callbacks:
onStarted
: Triggered when the timer starts.onFinished
: Triggered when the countdown ends.onChange
: Provides the remaining time at each interval.
- Custom UI Rendering: Use the
builder
function to create a dynamic UI based on the remaining time. - Lifecycle Management: Automatically cleans up timers when the widget is disposed.
Add this to your pubspec.yaml
file:
dependencies:
count_down_timer: ^<latest_version>
Then run:
flutter pub get
Here’s a basic example of how to use SimpleTimerCountDown
:
import 'package:flutter/material.dart';
import 'package:count_down_timer/count_down_timer.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('SimpleTimerCountDown Example')),
body: Center(
child: SimpleTimerCountDown(
duration: Duration(seconds: 10),
onStarted: () => print('Timer started!'),
onFinished: () => print('Timer finished!'),
onChange: (time) => print('Time remaining: $time'),
builder: (context, remainingTime) {
return Text(
remainingTime.inSeconds.toString(),
style: TextStyle(fontSize: 48),
);
},
),
),
),
);
}
}
Property | Type | Description |
---|---|---|
duration |
Duration |
The total countdown duration (required). |
interval |
Duration |
The interval at which updates occur (default: 1s). |
onStarted |
VoidCallback? |
Callback triggered when the timer starts. |
onFinished |
VoidCallback? |
Callback triggered when the countdown ends. |
onChange |
void Function(Duration)? |
Callback providing the remaining time. |
builder |
Widget Function(BuildContext, Duration)? |
Custom UI builder based on the remaining time. |
Use the builder
property to create dynamic UIs:
builder: (context, remainingTime) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Time Remaining:', style: TextStyle(fontSize: 20)),
Text(
'${remainingTime.inSeconds}s',
style: TextStyle(fontSize: 48, fontWeight: FontWeight.bold),
),
],
);
},
Contributions are welcome! If you have ideas for new features or improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
Love what you see?

Your support helps us keep building awesome tools like this!
We'd love to hear your thoughts! Feel free to create an issue on this repository if you have any suggestions or concerns.
You can also fill out this Google Form to provide feedback.
Start building with SimpleTimerCountDown
today!