nextSibling method

bool nextSibling()

Select next child node in parent of current node.

Consider tree:

       S1
      /  \
     S2  S3

if current node is S2, after call to this method S3 will be current node. If next sibling is selected, method returns true. If there is no next sibling this method do nothing, and returns false.

Implementation

bool nextSibling() {
  if (_current == _root) {
    return false;
  }
  ProcessingNode parent = _parenthood[_current]!;
  int index = parent.children.indexOf(_current);
  index++;
  if (index == parent.children.length) {
    return false;
  }
  _current = parent.children[index];
  return true;
}