runTasks method

Future<void> runTasks(
  1. List<NewAppTask> tasks,
  2. PostCreationAction postCreationAction
)

Implementation

Future<void> runTasks(
    List<NewAppTask> tasks, PostCreationAction postCreationAction) async {
  add(FromJsonProgressEvent(0));
  createdDocumentKey = null;
  createdDocumentId = null;
  var progressManager = ProgressManager(tasks.length, reportProgress);

  int i = 0;
  for (var task in tasks) {
    if (state is FromJsonActionCancelled) break;
    i++;
    try {
      await task();
    } catch (e) {
      print('Exception running task $i, error: $e');
    }
    progressManager.progressedNextStep();
  }
  postCreationAction(createdDocumentKey, createdDocumentId);
}