0 purchases
timercounter
timercounter #
倒计时工具.
Getting Started #
This project is a starting point for a Dart
package,
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
For help getting started with Flutter, view our
online documentation, which offers tutorials,
samples, guidance on mobile development, and a full API reference.
Usage #
It is really easy to use!
You should ensure that you add the timercounter as a dependency in your flutter project.
dependencies:
timercounter: ^0.0.4
copied to clipboard
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
TimerCounter _timeCounter;
int counter = 59;
@override
void dispose() {
_timeCounter.stop();
super.dispose();
}
void _beginTimer() {
_timeCounter = TimerCounter.begin(duration: 60, callback: (index){
setState(() {
counter = index;
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Text("$counter"),
RaisedButton(
onPressed: _beginTimer,
)
],
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.