I am try to create a timer app which have multiple countdown timer for different task. Issue, i am facing is that, if i start one timer, and press back button, timer stops. So i want, that timer to run till either it is being paused or timer ends and alerts the user or app is destroyed.Help me how can i do this using Flutter? Also i using sql-lite to store all timers.
I had a similar problem. The isolate won't solve it since the isolates life cycle is also linked to the main isolate(ui thread). I sort of created a workaround,i.e I used the dateTime property,so if the user chooses 30 minutes,the final Date time becomes Date time.now(Duration (minutes:30));. And a timer periodic function which runs every minute and finds the difference between the final date time and the datetime.now() so even if the os kills ur app while in the background application tray when u reopen the app,the time automatically updates to the change. I also used flutter notification package to alert the user when the timer value becomes zero
Isolates won't solve the problem. even isolates gets paused by the OS when the app is in the background. I have tried it (in Android10 timer runs for about 100 seconds before it gets paused by the system).
for your problem Android_Alarm_Manager package seems to be the solution. but it only supports android. no ios support yet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With