nextStep method

  1. @override
Step? nextStep({
  1. required Step step,
  2. required List<StepResult> previousResults,
  3. StepResult? questionResult,
})
override

Implementation

@override
Step? nextStep({
  required Step step,
  required List<StepResult> previousResults,
  StepResult? questionResult,
}) {
  record(step);
  final navigableTask = task as NavigableTask;
  final rule = navigableTask.getRuleByStepIdentifier(step.id);
  if (rule == null) {
    return nextInList(step);
  }
  switch (rule.runtimeType) {
    case DirectNavigationRule:
      return task.steps.firstWhere(
        (element) =>
            element.id ==
            (rule as DirectNavigationRule).destinationStepIdentifier,
      );
    case ConditionalNavigationRule:
      return evaluateNextStep(
        step,
        rule as ConditionalNavigationRule,
        previousResults,
        questionResult,
      );
  }
  return nextInList(step);
}