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

Unhandled Exception: Exception: Animated list state not found from GlobalKey<AnimatedListState> #12

Closed allanfann closed 1 year ago

allanfann commented 1 year ago

My code:

for (var element in _rootNode.childrenAsList) { if (element.key == parentKey.toString()) { try { element .add(TreeNode(key: context.uid.toString())); } catch (e) {} return; } }

Exception:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Animated list state not found from GlobalKey

0 _AnimatedListState.insertItem

tree_view.dart:495

1 AnimatedListController.insert

animated_list_controller.dart:65

2 AnimatedListController.insertAll

animated_list_controller.dart:70

3 AnimatedListController.expandNode

animated_list_controller.dart:116

4 AnimatedListController.handleAddItemsEvent

animated_list_controller.dart:208

5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)

6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)

7 _DelayedData.perform (dart:async/stream_impl.dart:515:14)

jawwad-hassan89 commented 1 year ago

Hi Alan, this issue has been resolved in the release 2.1.0. It can occur the treeview is updated before it is properly initialized. onTreeReady callback has been specifically added to address this issue. This issue will not occur when any changes are made to the tree after the onTreeReady callback is invoked.