notifyNodeRemoving method

Range notifyNodeRemoving (
  1. T node,
  2. void removeFn(
      ),
    1. {int index,
    2. AnimatedListController controller,
    3. TreeItemBuilder<T> builder}
    )

    This method has to be called when the node is about to be removed. Pass your function to removeFn that takes care of actually removing the node. If you also have the index of the corresponding list view item, that's better pass it through the index attribute, otherwise you can just omit it. If you pass a controller, the linked animated list view will be automatically notified. In this case you have to indicate a builder to build the removed subtree. If you don't pass a controller, a Range will be returned to indicate the range of items of the list view involved in the modification.

    Implementation

    Range notifyNodeRemoving(T node, void Function() removeFn,
        {int index,
        AnimatedListController controller,
        TreeItemBuilder<T> builder}) {
      assert(!equals(node, root)); // root cannot be removed!
      index = _ensureIndex(node, index);
      final from = index - (includeRoot ? 1 : 0);
      final to = from + countSubTree(node);
      return _notify(from, to, node, removeFn, index, controller, _remove,
          (from, count) {
        assert(builder != null);
        final subAdapter = subTreeOf(node, true);
        controller.notifyRemovedRange(from, count,
            (context, idx) => builder.call(subAdapter, context, idx, true));
      });
    }