next property
BuildBit?
next
The next bit in the tree.
Note: the next bit may not have the same parent or grandparent, it's only guaranteed to be within the same tree.
Implementation
BuildBit? get next {
BuildBit? x = this;
while (x != null) {
if (!x.hasParent) {
return null;
}
final siblings = x.parent._children ?? const [];
final i = siblings.indexOf(x);
if (i == -1) {
return null;
}
for (var j = i + 1; j < siblings.length; j++) {
final candidate = siblings[j];
if (candidate is BuildTree) {
final first = candidate.first;
if (first != null) {
return first;
}
} else {
return candidate;
}
}
x = x.parent;
}
return null;
}