AppTask constructor

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,
})

Create 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.

Implementation

AppTask({
  super.name,
  List<Measure>? measures,
  required this.type,
  this.title = '',
  super.description = '',
  this.instructions = '',
  this.minutesToComplete,
  this.expire,
  this.notification = false,
}) : super() {
  measures ??= <Measure>[];

  // Ensure that the completed app task data type is included in the measures.
  if (!measures.contains(
    Measure(type: '${CamsDataTypes.COMPLETED_APP_TASK}.$type'),
  )) {
    measures.add(Measure(type: '${CamsDataTypes.COMPLETED_APP_TASK}.$type'));
  }

  super.measures = measures.toSet().toList();
}