currentTimer method
Calculates the remaining time by comparing the current time with the saved background timestamp.
Returns the adjusted seconds remaining, or -1 if the timer expired
while the app was inactive.
Implementation
FutureOr<int> currentTimer() async {
final int savedTimer = await storageManager.timerStorage.loadSeconds() ?? 0;
final int savedTimeStamp =
await storageManager.backGroundTimeStampStorage.loadSeconds() ?? 0;
final int currentTimeStamp = currentTimeStampInEpoch();
final int diff = ((currentTimeStamp - savedTimeStamp) / 1000).floor();
final int timer = savedTimer - diff;
return timer > 0 ? timer : -1;
}