handleRemoveItemsEvent method

  1. @visibleForTesting
void handleRemoveItemsEvent(
  1. NodeRemoveEvent<INode> event
)

Implementation

@visibleForTesting
void handleRemoveItemsEvent(NodeRemoveEvent<INode> event) {
  for (final node in event.items) {
    if (!animatedListStateController.containsKey(node.path)) continue;

    //if item is in the root of the list, then remove the item
    if (animatedListStateController.list
        .any((item) => item.key == node.key)) {
      final index = animatedListStateController.indexOf(node);
      if (index < 0) continue;
      final removedItem = animatedListStateController.removeAt(index);

      if (removedItem.isExpanded) {
        //if the item is expanded, also remove its children
        animatedListStateController.removeAll(animatedListStateController.list
            .where((element) =>
                !element.isRoot &&
                (element.path).startsWith(removedItem.path))
            .toList());
      }
    }
  }
}