what is the most straight-forward way of dynamically changing the types of widgets displayed within the same Tab of a TabBarView, after pressing a button?
I dont want to completely move to a new page with a Navigator, because I want to keep the TabBar and stay in the same Tab, but replace the widgets that are displayed within that Tab.
Thank you to any helpers 🙂
2
Answers
The TabBar widget has a controller that handles tab switching internally without the need for a navigator.
If you want to simply avoid to use Navigator and display other widgets when the Tab on the TabBar where Tapped you can follow the example given on the Flutter docs.
If you pay attention, the body content on the first example is displayed according to the index of the TabBar Icon were Tapped. If you Tap the first Icon, it will show the first content on the TabBarView children.