remove method
Remove a node from this tree
Will throw if the node is not attached to the tree when the method is called
Implementation
void remove(TreeNode node, {bool notify = true}) {
assert(node.isAttached, '''
Node must be attached in order for it to be able to be removed
''');
final oldIndex = node.index;
final movedSiblings = node.siblings.sublist(oldIndex + 1);
_cascadeRemove(node);
if (_onMoved != null) {
for (final (index, sibling) in movedSiblings.indexed) {
_onMoved(sibling, oldIndex + index, sibling.parent, sibling.parent);
}
}
if (_onChanged != null) {
_onChanged();
}
if (notify) notifyListeners();
}