I am able to run timer when the screen is loaded but I want to run that same timer in background also is there a way to do that? and I also want to convert that 30 to 30 minutes need help.
static const maxMinutes = 30;
var minute = maxMinutes;
Timer timer;
void initState() {
// TODO: implement initState
super.initState();
startTimer();
}
void dispose() {
// TODO: implement dispose
super.dispose();
minute;
startTimer();
}
void startTimer(){
timer = Timer.periodic(Duration(seconds: 1), (timer) {
if(mounted) {
setState(() {
if (minute > 0) {
minute--;
} else {
timer.cancel();
}
});
}
});
}
timer is running but i want to run the timer in background