PendingTask constructor

PendingTask({
  1. required Iterable<String> files,
  2. required ResolvedHookTask resolvedTask,
  3. required bool isHalted(),
  4. required Iterable<int> completedTasks,
  5. required Iterable<int> startedTasks,
})

Implementation

PendingTask({
  required this.files,
  required this.resolvedTask,
  required bool Function() isHalted,
  required Iterable<int> completedTasks,
  required Iterable<int> startedTasks,
})  : _completedTasks = completedTasks,
      _startedTasks = startedTasks,
      _isHalted = isHalted {
  subTasks = resolvedTask.subTasks.map((task) {
    final subTask = PendingTask(
      files: files,
      resolvedTask: task,
      isHalted: isHalted,
      completedTasks: completedTasks,
      startedTasks: startedTasks,
    );

    return subTask;
  }).toList();

  Iterable<PendingTask> allTasks(PendingTask task) sync* {
    yield task;
    for (final subTask in task.subTasks) {
      yield* allTasks(subTask);
    }
  }

  taskMap = {
    for (final task in allTasks(this)) task.id: task,
  };
}