startPeriodicUpdateChecker method

Timer startPeriodicUpdateChecker(
  1. OnRelease onNewRelease, {
  2. Duration? interval,
  3. Release? currentRelease,
})

Starts a Timer with a periodic call to checkForUpdate.

  • onNewRelease is called when a new release is available.
  • interval is the Timer interval. Default: 1min.

Implementation

Timer startPeriodicUpdateChecker(OnRelease onNewRelease,
    {Duration? interval, Release? currentRelease}) {
  interval ??= Duration(minutes: 1);

  return Timer.periodic(interval, (_) async {
    var newRelease = await checkForUpdate(
        onNewRelease: onNewRelease, currentRelease: currentRelease);
    if (newRelease != null) {
      currentRelease = newRelease;
    }
  });
}