AppTask class
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.
RPAppTaskin carp_survey_package. measuresare 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
-
- Object
- Serializable
- TaskConfiguration
- AppTask
- Annotations
-
- @JsonSerializable.new(includeIfNull: false, explicitToJson: true)
Constructors
-
AppTask({String? name, List<
Measure> ? measures, required String type, String title = '', String? description = '', String instructions = '', int? minutesToComplete, Duration? expire, bool notification = false}) - Creates an app task that notifies the app when it is triggered.
-
AppTask.fromJson(Map<
String, dynamic> json) -
factory
Properties
- $type ↔ String?
-
The type name written to
__typein JSON; set tojsonTypeon creation.getter/setter pairinherited - backgroundTask → BackgroundTask
-
The list of background
measuresas aBackgroundTask.no setter - description ↔ String
-
A short description (one line) of this task. Can be used in the app.
getter/setter pairinherited-setteroverride-getter
- expire ↔ Duration?
-
How long this task stays on the AppTaskController's queue before it
expires and is removed. If
null, the task never expires.getter/setter pair - fromJsonFunction → Function
-
The generated function that converts a JSON map to an object of this type.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- instructions ↔ String
-
A longer instruction text explaining how a user should perform this task.
getter/setter pair
- jsonType → String
-
The
__typeused for JSON serialization of this class.no setterinherited -
measures
↔ List<
Measure> ? -
The data which needs to be collected/measured passively as part of this task.
getter/setter pairinherited
- minutesToComplete ↔ int?
-
How many minutes will it take for the user to perform this task?
Typically shown to the user before engaging into this task.
If
nullthe task has no completion time.getter/setter pair - name ↔ String
-
A name which uniquely identifies the task.
getter/setter pairinherited
- notification ↔ bool
-
Whether to send a notification to the user when the task is triggered.
Default is
false.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title ↔ String
-
A title for this task. Can be used in the app.
getter/setter pair
- type ↔ String
-
The type of task, e.g. SURVEY_TYPE. Any string is allowed.
getter/setter pair
Methods
-
addMeasure(
Measure measure) → void -
Add
measureto this task.inherited -
addMeasures(
Iterable< Measure> list) → void -
Add a
listof measures to this task.inherited -
getAllExpectedDataTypes(
) → Set< String> -
Get data types of all data which may be collected, either passively as part
of task measures, or as the result of user interactions, for this task.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeMeasure(
Measure measure) → void -
Remove
measurefrom this task.inherited -
toJson(
) → Map< String, dynamic> -
Returns a JSON map of this object, including the
__typeproperty.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- AUDIO_TYPE → const String
- An audio app task. Used in the carp_audio_package.
- COGNITIVE_ASSESSMENT_TYPE → const String
-
A cognitive assessment app task. Used in the carp_survey_package for
RPAppTasks. - HEALTH_ASSESSMENT_TYPE → const String
- An app task collecting health data. Used in the carp_health_package.
- IMAGE_TYPE → const String
- An image app task. Used in the carp_audio_package.
- INFORMED_CONSENT_TYPE → const String
- An informed consent app task.
- SENSING_TYPE → const String
- A background sensing user task which can be started and stopped by the user.
- SURVEY_TYPE → const String
-
A survey app task. Used in the carp_survey_package for
RPAppTasks. - VIDEO_TYPE → const String
- A video app task. Used in the carp_audio_package.