Hello I have a tab bar in Flutter and I want to disable swiping between tabs
// Set the bottom navigation bar bottomNavigationBar: new Material( // set the color of the bottom navigation bar color: const Color(0xFFF7F7F7), // set the tab bar as the child of bottom navigation bar child: new TabBar( tabs: <Tab>[ new Tab( // set icon to the tab icon: new Icon(Icons.home,color: Colors.black), ), new Tab( icon: new Icon(Icons.favorite,color: Colors.black), ), new Tab( icon: new Icon(Icons.search,color: Colors.black), ), new Tab( icon: new Icon(Icons.settings,color: Colors.black), ), ], // setup the controller controller: controller, ), ), ); } }
I am moving tabs on clicking each tab bar button and I want to disable swiping thank you
Question answered by Sunisha S (source). Use IgnorePointer. It will disable the click action of tabs.
DefaultTabController is an inherited widget that is used to share a TabController with a TabBar or a TabBarView. It's used when sharing an explicitly created TabController isn't convenient because the tab bar widgets are created by a stateless parent widget or by different parent widgets.
TabBar with labels without AppBar Instead, we can use PreferredSize widget. Since TabBar has preferredSize , we should use it to decide the height. Yes!
you can achieve that by changing how the page view should respond to user input using the physics
property. and we have a NeverScrollableScrollPhysics
for that purpose so just change physics
to that like this :
TabBarView( physics: NeverScrollableScrollPhysics(), controller: tabcontroler, children: <Widget>[ Container(color: Colors.red), Container(color: Colors.green), Container(color: Colors.blue), ], ),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With