flutterhidetabbarvisible

Flutter : Control a tab bar action visible or hide


my application give the user to control the tab bar to visible or hide according what they want. User can set which tab bar they want in the system. So is it possible to make it happen? Really appreciate for any help. Because I'm kinda newbie in this Flutter.

Attach here is the code example.

bottom: TabBar(
      controller: _controller,
      isScrollable: true,
      tabs: [
         Tab(
           text: 'Consignment',
         ),
         Tab(
           text: 'POD',
         ),
         Tab(
           text: 'Invoices',
         ),
       ],
     )),
 body: const TabBarView(
            children: [
              Icon(Icons.directions_car),
              Icon(Icons.directions_transit),
              Icon(Icons.directions_bike),
            ],

Solution

  • Hello @Aqilah Mokhtarudin.
    Welcome on StackOverflow.

    It's totally possible, what you would have to do, is to make your list of Tabs a variable. Then add or remove items from the list, using the corresponding methods.

    You will have to make the children of your TabBarView corresponding to the number of elements of your list.