|
| 1 | +# Circular Countdown Timer |
| 2 | + |
| 3 | +Make an animated countdown timer using Circular Countdown Timer. |
| 4 | + |
| 5 | +# Getting Started |
| 6 | + |
| 7 | +To use this plugin, add `circular_countdown_timer` as a [dependency in your pubspec.yaml file.](https://flutter.dev/docs/development/packages-and-plugins/using-packages) |
| 8 | + |
| 9 | +# Example |
| 10 | + |
| 11 | +```dart |
| 12 | +import 'package:flutter/material.dart'; |
| 13 | +import 'package:circular_countdown_timer/circular_countdown_timer.dart'; |
| 14 | +
|
| 15 | +void main() => runApp(MyApp()); |
| 16 | +
|
| 17 | +class MyApp extends StatelessWidget { |
| 18 | + @override |
| 19 | + Widget build(BuildContext context) { |
| 20 | + return MaterialApp( |
| 21 | + debugShowCheckedModeBanner: false, |
| 22 | + title: 'Circular Countdown Timer Demo', |
| 23 | + theme: ThemeData( |
| 24 | + primarySwatch: Colors.blue, |
| 25 | + ), |
| 26 | + home: MyHomePage(title: 'Circular Countdown Timer'), |
| 27 | + ); |
| 28 | + } |
| 29 | +} |
| 30 | +
|
| 31 | +class MyHomePage extends StatefulWidget { |
| 32 | + MyHomePage({Key key, this.title}) : super(key: key); |
| 33 | +
|
| 34 | + final String title; |
| 35 | +
|
| 36 | + @override |
| 37 | + _MyHomePageState createState() => _MyHomePageState(); |
| 38 | +} |
| 39 | +
|
| 40 | +class _MyHomePageState extends State<MyHomePage> { |
| 41 | + @override |
| 42 | + Widget build(BuildContext context) { |
| 43 | + return Scaffold( |
| 44 | + appBar: AppBar( |
| 45 | + title: Text(widget.title), |
| 46 | + ), |
| 47 | + body: Center( |
| 48 | + child: CircularCountDownTimer( |
| 49 | + // Countdown duration in Seconds |
| 50 | + duration: 10, |
| 51 | +
|
| 52 | + // Width of the Countdown Widget |
| 53 | + width: MediaQuery.of(context).size.width / 2, |
| 54 | +
|
| 55 | + // Height of the Countdown Widget |
| 56 | + height: MediaQuery.of(context).size.height / 2, |
| 57 | +
|
| 58 | + // Default Color for Countdown Timer |
| 59 | + color: Colors.white, |
| 60 | +
|
| 61 | + // Filling Color for Countdown Timer |
| 62 | + fillColor: Colors.red, |
| 63 | +
|
| 64 | + // Border Thickness of the Countdown Circle |
| 65 | + strokeWidth: 5.0, |
| 66 | +
|
| 67 | + // Text Style for Countdown Text |
| 68 | + countdownTextStyle: TextStyle( |
| 69 | + fontSize: 22.0, |
| 70 | + color: Colors.black87, |
| 71 | + fontWeight: FontWeight.bold), |
| 72 | +
|
| 73 | + // Count Order i.e forward or reverse, true for reverse and false for forward order |
| 74 | + reverseOrder: false, |
| 75 | +
|
| 76 | + // Function which will execute when the Countdown Ends |
| 77 | + onCountDownComplete: () { |
| 78 | + // Here, do whatever you want |
| 79 | + print('Countdown Ended'); |
| 80 | + }, |
| 81 | + ))); |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +# Output |
| 87 | + |
| 88 | + |
0 commit comments