initialize method
Initialize and set up the app controller.
This will restore the queue of UserTasks from persistent storage.
If enableNotifications is true, a notification will be added to
the phone's notification system when a task is enqueued via the
enqueue method.
Implementation
Future<void> initialize({bool enableNotifications = true}) async {
_notificationsEnabled = enableNotifications;
// Restore previous queue from persistent storage.
await _restoreQueue();
// set up a timer which expires tasks in the queue once an hour
_garbageCollector = Timer.periodic(const Duration(hours: 1), (_) {
for (var task in userTasks) {
if (task.expiresIn?.isNegative ?? false) expire(task.id);
}
});
}