withChildren method
Rebuilds itself with a new list of child nodes. The order and number of child nodes must match the return value of children. Leaf nodes return themselves.
Implementation
@override
LatexNode withChildren(List<LatexNode> newChildren) {
final newBase = newChildren[0];
final newIndices = <(bool, LatexNode)>[];
for (int i = 0; i < indices.length; i++) {
newIndices.add((indices[i].$1, newChildren[i + 1]));
}
return TensorNode(newBase, newIndices, sourceRange: sourceRange);
}