embraceitmobile / animated_tree_view

Animated TreeView based on AnimatedList allows building fully customizable Nodes that can be nested to infinite levels and children.
https://pub.dev/packages/animated_tree_view
MIT License
49 stars 23 forks source link

How to refresh UI state for node after check-box is clicked on such node? #22

Open UlyssesAlves opened 11 months ago

UlyssesAlves commented 11 months ago

I need a tree with a checkbox on each of its nodes. My current problem is that the checkbox ui state does not change right after I click the checkbox for that node, but it is then updated correctly when I expand or shrink the tree.

How can I make this work so that when a checkbox os pressed it's UI wii change too on the node?

jawwad-hassan89 commented 9 months ago

Wrap the node widget in a ValueListenableBuilder, and use the node.listenableData as the value to listen. Use node.data to assign or get the data. The node extends the ValueListenable, so it can be used as a ChangeNotifier or ValueListenable.

Apologize for the late reply.

//sample code
 ValueListenableBuilder(
      valueListenable: node.listenableData,
      builder: (context, page, child) {
        return SomeWidgetHere();
      },
    );