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