getStepAfterStep method Null safety

  1. @override
RPStep? getStepAfterStep(
  1. RPStep? step,
  2. RPTaskResult? result
)
override

Returns the step after a specified step if there's any. If the specified step is null then it returns the first step.

Returns null if step was the last one in the sequence.

Implementation

@override
RPStep? getStepAfterStep(RPStep? step, RPTaskResult? result) {
  if (step == null) return steps.first;
  int nextIndex = steps.indexOf(step) + 1;
  if (nextIndex < steps.length) return steps[nextIndex];
  return null;
}