init method

Future<void> init()

Initializes the cubit by checking local storage for an existing timer.

If a timer was previously running, it calculates the elapsed time since the app was last active and resumes the countdown if time remains.

Implementation

Future<void> init() async {
  final int timer = await currentTimer();

  log(timer.toString());
  if (timer > 0) {
    emit(TimerState(secondsRemaining: timer, isPaused: true));
    _startTimer(timer);
  } else {
    emit(TimerState(secondsRemaining: 0, isPaused: true));
  }
}