collapse method
关闭 node
Implementation
void collapse(EasyTreeNode<E> node) {
assert(_isInitialized);
if (node.expanded && _nodes != null) {
node.expanded = false;
List<EasyTreeNode<E>> modified = node.getModifiedChildren;
for (EasyTreeNode<E> item in modified) {
int index = _nodes!.indexWhere((element) => element.key == item.key);
if (index != -1) {
State<StatefulWidget>? _state = _listKey.currentState;
if (_state is SliverAnimatedListState) {
_state.removeItem(index, (context, animation) {
return _removedItemBuilder(item, context, animation);
});
} else if (_state is AnimatedListState) {
_state.removeItem(index, (context, animation) {
return _removedItemBuilder(item, context, animation);
});
}
_nodes!.removeWhere((element) => item.key == element.key);
}
}
}
}