Skip to content

AppTask

A task that the user does in the app, like filling in a survey.

When its trigger fires, an AppTaskExecutor wraps the task in a UserTask and puts it on the queue of the AppTaskController. The app shows the queue as a task list, and the user starts, completes, or cancels the task.

Key points:

  • type says what kind of task it is, e.g. SURVEY_TYPE. Sampling packages provide subclasses, e.g. RPAppTask in carp_survey_package.
  • measures are collected in the background while the task is running.
  • A dk.cachet.carp.completedapptask.<type> measure is always added, so a CompletedAppTask is collected when the task is done.
  • expire removes the task from the queue; notification sends a notification via the NotificationManager.
protocol.addTaskControl(
  RecurrentScheduledTrigger(type: RecurrentType.daily, time: TimeOfDay(hour: 8)),
  AppTask(type: AppTask.SURVEY_TYPE, title: 'Daily survey', notification: true),
  phone,
);
Inheritance
Annotations

Constructors

AppTask.fromJson

AppTask.fromJson(
  1. Map<String, dynamic> json
)

AppTask

AppTask({
  1. String? name,
  2. List<Measure>? measures,
  3. required String type,
  4. String title = '',
  5. String? description = '',
  6. String instructions = '',
  7. int? minutesToComplete,
  8. Duration? expire,
  9. bool notification = false,
})

Creates an app task that notifies the app when it is triggered.

name is a unique name of the task. measures is the list of measures to be collected in the background when this app task is started. type provide a unique type for this kind of app task.

Constants

AUDIO_TYPE

String const AUDIO_TYPE

An audio app task. Used in the carp_audio_package.

COGNITIVE_ASSESSMENT_TYPE

String const COGNITIVE_ASSESSMENT_TYPE

A cognitive assessment app task. Used in the carp_survey_package for RPAppTasks.

HEALTH_ASSESSMENT_TYPE

String const HEALTH_ASSESSMENT_TYPE

An app task collecting health data. Used in the carp_health_package.

IMAGE_TYPE

String const IMAGE_TYPE

An image app task. Used in the carp_audio_package.

String const INFORMED_CONSENT_TYPE

An informed consent app task.

SENSING_TYPE

String const SENSING_TYPE

A background sensing user task which can be started and stopped by the user.

SURVEY_TYPE

String const SURVEY_TYPE

A survey app task. Used in the carp_survey_package for RPAppTasks.

VIDEO_TYPE

String const VIDEO_TYPE

A video app task. Used in the carp_audio_package.

Properties

backgroundTask

BackgroundTask get backgroundTask

The list of background measures as a BackgroundTask.

description

String get description
override
set description (String? value)
inherited

A short description (one line) of this task. Can be used in the app.

expire

Duration? expire
getter/setter pair

How long this task stays on the AppTaskController's queue before it expires and is removed. If null, the task never expires.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

instructions

String instructions
getter/setter pair

A longer instruction text explaining how a user should perform this task.

minutesToComplete

int? minutesToComplete
getter/setter pair

How many minutes will it take for the user to perform this task? Typically shown to the user before engaging into this task. If null the task has no completion time.

notification

bool notification
getter/setter pair

Whether to send a notification to the user when the task is triggered. Default is false.

title

String title
getter/setter pair

A title for this task. Can be used in the app.

type

String type
getter/setter pair

The type of task, e.g. SURVEY_TYPE. Any string is allowed.

Methods

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.