getStepBeforeStep method Null safety

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

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.


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;