Dynamically generate tree

Issue #7 resolved
Albert-Jan Plate created an issue

Hi! First off, I love how this Widget works! Thank you so much!

I initialize the controller in my didChangeDependencies() like this:

_treeViewController = TreeViewController(
      children: [
          label: 'Location',
          key: 'location',

But for some reason Iā€™m not able to dynamically add items to it from my stream:

_treeViewController.addNode('location', Node(key: 'id0', label: 'Sub location name'));

Am I missing something? Would love to hear from you šŸ™‚

Comments (3)

  1. Kevin Armstrong

    Hi, you are very close in your implementation but the addNode method only returns a new list object:


    You have to explicitly set the state yourself to see an update.
    Somewhere in your code you should add the following statement where the state will be updated:


      //add line below
     _treeViewController = _treeViewController.withAddNode('location', Node(key: 'id0', label: 'Sub location name'));


  2. Albert-Jan Plate reporter

    Thanks for the clarification, everything is working as expected now! Thanks for this great widget!

  3. Log in to comment