getStepBeforeStep method Null safety

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

Returns the step that precedes the specified step, if there is one. If the specified step is null then it returns the last step.

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

Implementation

@override
RPStep? getStepBeforeStep(RPStep? step, RPTaskResult? result) {
  if (step == null) return steps.last;
  int nextIndex = steps.indexOf(step) - 1;
  if (nextIndex >= 0) return steps[nextIndex];
  return null;
}