Add Timer using Flutter

In this article I will share with timer view, If you need to execute a piece of code after some time in Flutter you have to use Timer class. Timer class will allow specifying the time which you need to delay the execution and after that time period code will be executed inside the Timer.

void timer() {
Timer.periodic(
    Duration(seconds: 1),
       (Timer time) {
	print("time: ${time.tick}");
       if (time.tick == 5) {
    	time.cancel();
    	print('Timer Cancelled');
         }
      },

   );

}

I hope it will help you. 

Tags: