Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a widget from tree

Tags:

flutter

dart

I want to be able to remove a widget from tree, or remove a child of a widget. I tried to use states to change a widget to null but it's returning an error. Is there a solution ? Here is the error https://gist.github.com/litekangel/e2037cf5dc4dbd9c0c0a9860ad3b0270

I finally found a solution to hide/remove a widget : I just replaced it by an empty widget (may be I will add a small animation) but I am still looking for a cleaner way to do this.

like image 630
Litekangel Avatar asked Dec 13 '22 23:12

Litekangel


1 Answers

In flutter you don't really update a tree of widget you actually generate a new tree every time you need to change it. So you only have to change the returned value of your widget build function.

like image 106
Alexandre Ardhuin Avatar answered Jan 28 '23 00:01

Alexandre Ardhuin