i want running next step
- mainTimerStart run
- after 2sec
- print 'Fist Timer End'
- mainTimerStart run
- after 3sec
- print 'Second Timer End'
But.... now All the step work at once.
look at my code
button function code
onPressed: () async {
await timeSetController.mainTimerStart(2);
print('First Timer End');
await timeSetController.mainTimerStart(3);
print('Second Timer End');
},
mainTimerStart function code
Future<void> mainTimerStart(int setMainTime) async {
isMainTimerRun(true);
time(setMainTime);
mainTimer = Timer.periodic(const Duration(seconds: 1), (timer) async {
if (time <= 1) {
mainTimer?.cancel();
time(0);
isMainTimerRun(false);
} else {
time--;
}
});
}