Have you wanted to display a persistent model from a child widget in flutter?
if you are a mobile developer the answer might be yes...
here are a couple of reason you might need it, you need to show a model but you need your model to show on top of all widget not the child widget, the solution of cause as might guess us to go to the root widget so you can show the model from there, the problem is that by the time you try to do that the flutter will be in process of rebuilding the widget tree and therefore it can not insert a widget during building phase..... aha now you know the problem how do you solve it then???
the answer is to wrap up the new model you want to insert into widget tree like this WidgetsBinding.instance
.addPostFrameCallback((_) => _showBottomSheet());
this will ensure that the flutter SDK has done rebuilding new widget tree....
I guess this has helped you a lot. thank you please give me feedback about my writing.
Top comments (0)