insertAtIndex method
Inserts a node at position index in parent.
The index value must be non-negative and no greater than length.
Implementation
void insertAtIndex(int index, dynamic parent, NodeData newNode,
{bool closeCanInsert = false}) {
if (parent == null) {
assert(index <= data!.length);
if (!closeCanInsert) {
data!.insert(index, newNode);
_insertRootControllerAt(index);
notifyListeners();
}
return;
}
assert(index <= parent.children.length);
if (!closeCanInsert) {
if (!isExpanded(parent)) {
return;
}
}
parent.children.insert(index, newNode);
_insertItemAtIndex(index, parent, isIndex: true);
notifyListeners();
}