0

I'm using circular_countdown_timer of flutter.On every Oncomplte of the circular_countdown_timer restart timer.it is working nicely on foreground but its not working when app is in background and phone is locked.

how to work restart function in oncomplete of circularCountDownTimer pkg of flutter.

pmatatias
  • 3,491
  • 3
  • 10
  • 30

1 Answers1

0

Firstly, you can use storage to save the current time (and also total duration). Then, here is the next scenario:

When the timer starts by the user, can save something to Shared Preferences (which can be the simplest solution) that will record the current time and total duration of your countdown.

When the app is locked or running in the background, use the code you currently have. If the user restarts the application, you can check with your code (you can use your saved values for storage).

Then, you can write calculation logic according to your shared values which are duration and current time accordingly.

This might address your issue because when the app is background, you can use only these values to control your timer.

Nijat Namazzade
  • 652
  • 5
  • 15