notifyNodeCollapsing method

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

    This method has to be called when the node is about to be collapsed. Pass your function to collapseFn that takes care of actually collapsing 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 collapsed 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 notifyNodeCollapsing(T node, void Function() collapseFn,
        {int index,
        AnimatedListController controller,
        TreeItemBuilder<T> builder}) {
      index = _ensureIndex(node, index);
      final from = index + (includeRoot ? 0 : 1); // first child index
      final to = from + _countSubNodesOf(node);
      return _notify(from, to, node, collapseFn, index, controller, _remove,
          (from, count) {
        assert(builder != null);
        final subAdapter = subTreeOf(node);
        controller.notifyRemovedRange(from, count,
            (context, idx) => builder.call(subAdapter, context, idx, true));
      });
    }