getNextUntilMustStopStep method

DestinationWithMovedStepCount getNextUntilMustStopStep (
  1. int num,
  2. {Direction firstDirection}
)

Implementation

DestinationWithMovedStepCount getNextUntilMustStopStep(int num, {Direction firstDirection}) {
  var current = this;
  var count = 0;
  if (firstDirection != null) {
    current = current._getNext(firstDirection);
    count++;
  }
  while (current != null && count < num) {
    if (current.mustStop) break;
    final next = current._getNext();
    if (next == null) break;
    current = next;
    count++;
  }
  return DestinationWithMovedStepCount(wantToMoveCount: num, movedCount: count, destination: current);
}