wrapChildToToggleNode static method

Widget wrapChildToToggleNode({
  1. required TreeSliverNode<Object?> node,
  2. required Widget child,
})

A wrapper method for triggering the expansion or collapse of a TreeSliverNode.

Used as part of TreeSliver.defaultTreeNodeBuilder to wrap the leading icon of parent TreeSliverNodes such that tapping on it triggers the animation.

If defining your own TreeSliver.treeNodeBuilder, this method can be used to wrap any part, or all, of the returned widget in order to trigger the change in state for the node.

Implementation

static Widget wrapChildToToggleNode({
  required TreeSliverNode<Object?> node,
  required Widget child,
}) {
  return Builder(builder: (BuildContext context) {
    return GestureDetector(
      onTap: () {
        TreeSliverController.of(context).toggleNode(node);
      },
      child: child,
    );
  });
}