sooxie / list_treeview

A treeview for Flutter. Based on the listview.
MIT License
64 stars 23 forks source link

Content of Node is not refreshing #9

Open ynnob opened 3 years ago

ynnob commented 3 years ago

Hey,

we use BloC to handle our state of the View. After a navigation event and returning to the view that contains the ListTreeView i reload the Data that is displayed by the ListTreeView.

If i set the treeData() a second time, the itemBuilder of the ListTreeView uses the old data of the initial TreeData() call.

How can i force the ListTreeView to reload the Data so changes are displayed? In my example i have an item with an int value that is display in the ListTreeView. Inside the itemBuilder i do something like this:

treeViewController.treeData(lChecklistNodeData);
return ListTreeView(
      controller: treeViewController,
      itemBuilder: (BuildContext context, NodeData data) {
        ChecklistNodeData item = data as ChecklistNodeData;

return Text('${item.intValue}');
});

As i said this is working fine the first time, but when i reload the data and the build() method is retriggered the Data in the itemBuilder function is not refreshed. I checked the data i pass to treeData() and it is definitly the new data. But still the itemBuilder uses the data of the first set of treeData().

I managed to refresh the Parent items by resetting the TreeViewController treeViewController = new TreeViewController();

but this leads to only the parents showing up. All child elements are missing after the second rebuild if i do this.

Thanks in advance

sooxie commented 3 years ago

Ok, I will try the situation you said, please wait a moment.

sooxie commented 3 years ago

Hi buddy, now you can refresh the data with _controller.rebuild(). I'll make it easier to refresh the data and fix it when I have time.

ynnob commented 3 years ago

Hi buddy, now you can refresh the data with _controller.rebuild(). I'll make it easier to refresh the data and fix it when I have time.

Thanks for your response! Could you reproduce the issue? I will give it a try on Monday and I will let you know if it worked.

Thanks

ynnob commented 3 years ago

Hi buddy, now you can refresh the data with _controller.rebuild(). I'll make it easier to refresh the data and fix it when I have time.

Hey you did not update the extension. There is no new version. If i use _controller.rebuild() nothing happens. The Values of the TreeView still do not update.

dipen-apptrait commented 2 years ago

Hey, have you found any solution for content refreshing?

lixp185 commented 2 years ago

这是一封自动回复邮件。已经收到您的来信,我会尽快回复。

ynnob commented 2 years ago

Hey, have you found any solution for content refreshing?

Nope. Still no solution.

dipen-apptrait commented 2 years ago

Hey! I got the solution for a content refresh. _controller!.dispose(); _controller = TreeViewController(); // -- Call function to fetch updated data

setState(() { _controller!.rebuild(); });

sooxie commented 2 years ago

@Bonnyfication You can use this function

_controller!.rebuild();

lixp185 commented 2 years ago

这是一封自动回复邮件。已经收到您的来信,我会尽快回复。