clipChildrenBetween method
Implementation
ParentableNode<GreenNode> clipChildrenBetween(int pos1, int pos2) {
final childIndex1 = childPositions.slotFor(pos1);
final childIndex2 = childPositions.slotFor(pos2);
final childIndex1Floor = childIndex1.floor();
final childIndex1Ceil = childIndex1.ceil();
final childIndex2Floor = childIndex2.floor();
final childIndex2Ceil = childIndex2.ceil();
GreenNode? head;
GreenNode? tail;
if (childIndex1Floor != childIndex1 &&
childIndex1Floor >= 0 &&
childIndex1Floor <= children.length - 1) {
final child = children[childIndex1Floor];
if (child is TransparentNode) {
head = child.clipChildrenBetween(
pos1 - childPositions[childIndex1Floor],
pos2 - childPositions[childIndex1Floor]);
} else {
head = child;
}
}
if (childIndex2Ceil != childIndex2 &&
childIndex2Floor >= 0 &&
childIndex2Floor <= children.length - 1) {
final child = children[childIndex2Floor];
if (child is TransparentNode) {
tail = child.clipChildrenBetween(
pos1 - childPositions[childIndex2Floor],
pos2 - childPositions[childIndex2Floor]);
} else {
tail = child;
}
}
return this.updateChildren(<GreenNode>[
if (head != null) head,
for (var i = childIndex1Ceil; i < childIndex2Floor; i++) children[i],
if (tail != null) tail,
]);
}