timer_count_down 1.0.2 timer_count_down: ^1.0.2 copied to clipboard
Simple CountDown timer. Using for create a simple timer. It's pure all
import 'package:flutter/material.dart';
import 'package:timer_count_down/timer_count_down.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Countdown'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Countdown(
seconds: 20,
build: (_, double time) => Text(time.toString()),
interval: Duration(milliseconds: 100),
onFinished: () {
print('Timer is done!');
},
),
),
);
}
}