AppTaskController class
Keeps the queue of UserTasks that the user needs to do.
A singleton. When an AppTask is triggered, its AppTaskExecutor is wrapped in a UserTask by a UserTaskFactory and enqueued here. The app shows userTaskQueue to the user (e.g., as a task list) and listens to userTaskEvents for changes.
Key points:
- Asks the NotificationManager to notify about each enqueued task, if notifications are enabled in initialize.
- Tasks from schedulable triggers are first buffered, then enqueueBufferedTasks schedules as many as the OS notification limit allows.
- Tasks whose AppTask.expire has passed are expired once an hour.
- The queue is restored from the PersistenceService on initialize.
See also UserTask, whose callbacks the app calls to start and finish a task.
Constructors
- AppTaskController()
-
Returns the singleton AppTaskController.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- notificationManager → NotificationManager
-
The client's notification controller for sending notifications to the user.
no setter
- notificationsEnabled → bool
-
Whether this controller sends notifications to the user.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- taskCompleted → int
-
The number of done tasks in the userTaskQueue.
no setter
- taskExpired → int
-
The number of expired tasks in the userTaskQueue.
no setter
- taskPending → int
-
The number of UserTaskState.enqueued tasks in the userTaskQueue.
no setter
- taskTotal → int
-
The number of tasks in the userTaskQueue.
no setter
-
userTaskEvents
→ Stream<
UserTask> -
Emits a UserTask each time the controller changes it.
no setter
-
userTaskQueue
→ List<
UserTask> -
The UserTasks whose trigger time has passed.
no setter
-
userTasks
→ List<
UserTask> -
All UserTasks, including those scheduled to trigger in the future.
no setter
Methods
-
buffer(
AppTaskExecutor< AppTask> executor, TaskControl taskControl, {DateTime? triggerTime, bool sendNotification = true}) → void -
Buffers
executorfromtaskControlto be enqueued later. -
dequeue(
String id) → void -
Removes the UserTask with
idand cancels its notification. -
dispose(
) → void - Stops the expiry check and closes userTaskEvents.
-
done(
String id, [Data? result]) → void -
Marks the UserTask with
idas done, with an optionalresult. -
enqueue(
AppTaskExecutor< AppTask> executor, {DateTime? triggerTime, bool sendNotification = true}) → Future<UserTask?> -
Creates a UserTask for the AppTask run by
executorand enqueues it. -
enqueueBufferedTasks(
) → Future< void> - Enqueues the tasks buffered with buffer, earliest first.
-
expire(
String id) → void -
Marks the UserTask with
idas expired, unless it is done. -
getUserTask(
String id) → UserTask? -
Returns the UserTask with
id, ornullif no task is found. -
initialize(
{bool enableNotifications = true}) → Future< void> - Restores the queue of UserTasks from persistent storage.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onNotification(
String id) → void -
Called when the user taps the OS notification of the UserTask with
id. -
registerUserTaskFactory(
UserTaskFactory factory) → void -
Registers
factoryfor each AppTask.type in UserTaskFactory.types. -
removeStudy(
SmartphoneStudy study) → void -
Removes all tasks of
studyand cancels their notifications. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited