Countdown timer in flutter | Restartable timer in flutter



RestartableTimer class


1- Set RestartableTimer
2- Set Duration
3. Set Callback


The restartable timer implements Timer. It restarts from its initial position and can be restart any number of time. It provide a callback when given time passed.



import 'package:async/async.dart';

RestartableTimer(
  Duration _givenTime,
  ZoneCallback _zoneCallback
)


Example-

Method call when timer finishes its execution


_onTimerFinished() {
     // TODO: Perform some action
     print('Timer Finished');
}

RestartableTimer _restartTimer = RestartableTimer(Duration(seconds: 10),_onTimerFinished);

onPressed(){
   _restartTimer.reset();
}


To reset the timer

 _restartTimer.reset();

To cancel the timer

 _restartTimer.cancel();





Previous
Next Post »

1 comments:

Click here for comments
Anonymous
admin
September 24, 2020 at 2:54 AM ×

I am so much excited after reading your blog. Your blog is very much innovative and much helpful for any industry as well as in person.

flutter entwicklung

Congrats bro Anonymous you got PERTAMAX...! hehehehe...
Reply
avatar