scheduled_timer 2.0.1 copy "scheduled_timer: ^2.0.1" to clipboard
scheduled_timer: ^2.0.1 copied to clipboard

A simple timer that can be scheduled to run at a specific time, and will restore it's scheduled time across app restarts.

ScheduledTimer #

A simple timer that can be scheduled to run at a specific time.

Please note: This timer only runs when the app is running - it does not schedule anything to be run in the background using OS-specific scheduling mechanisms, nor does it attempt to wake the device or app.

How it works #

A ScheduledTimer can be scheduled to run at a specific time, rather than after a certain amount of time (which is the case with the normal Flutter Timer).

The scheduled time is automatically stored (using SharedPreferences) and retrieved after an app restart.

If a scheduled time was missed (i.e. the app was not running at the time), ScheduledTimer can optionally call a user defined callback function. This makes it possible to reschedule or execute the timer immediately.

Usage #

ScheduledTimer myTimer;

myTimer = ScheduledTimer(
  id: 'myTimer', 
  onExecute: (){
    print('Executing myTimer');
  },
  defaultScheduledTime: DateTime.now().add(Duration(minutes: 10)),
  onMissedSchedule: (){
    print('myTimer missed the scheduled time');
    myTimer.execute(); // Execute onExecute() immediately
  }
);
16
likes
130
pub points
81%
popularity

Publisher

verified publishermagnuswikhog.com

A simple timer that can be scheduled to run at a specific time, and will restore it's scheduled time across app restarts.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, shared_preferences

More

Packages that depend on scheduled_timer