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
59 stars 29 forks source link

How to detect if node is expanding or shrinking in onItemTap method? #39

Closed tomekit closed 9 months ago

tomekit commented 9 months ago

I am trying to dynamically lazy load data as long as user clicks on the e.g. Folder.

I was thinking about capturing the click using onItemTap and then detect if node is "expanding" in order to dynamically load and inject nodes.

Unfortunately in my case (using file_explorer_sample.dart) example: node.isExpanded is always true regarding if node is opening or closing.

onItemTap: (node) async {
  if (node.isExpanded) {
   // Why always true?
  }
}

Any idea how to detect current state of the node in onItemTap?

Related: https://github.com/embraceitmobile/animated_tree_view/issues/37

tomekit commented 9 months ago

We've addressed that in: https://github.com/embraceitmobile/animated_tree_view/compare/main...tomekit:animated_tree_view:main

Basically the: await was needed on the: onToggleExpansion method. Feel free to pull it upstream.