禁用TabBar抖动中的滑动选项卡 [英] disable swiping tabs in TabBar flutter
本文介绍了禁用TabBar抖动中的滑动选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我在Flutter中有一个标签栏,我想禁用标签之间的滑动
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
推荐答案
您可以通过使用physics
属性更改页面视图对用户输入的响应方式来实现.为此,我们有一个NeverScrollableScrollPhysics
,因此只需将physics
更改为这样:
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),
],
),
这篇关于禁用TabBar抖动中的滑动选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文