您好,我在 Flutter 中有一个标签栏,我想禁用标签之间的滑动
// 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,
),
),
);
}
}
我在点击每个标签栏按钮时移动标签,我想禁用滑动谢谢
最佳答案
您可以通过使用 physics
属性更改页面 View 对用户输入的响应方式来实现这一点。我们有一个 NeverScrollableScrollPhysics
用于此目的,所以只需将 physics
更改为这样:
TabBarView(
physics: NeverScrollableScrollPhysics(),
controller: tabcontroler,
children: <Widget>[
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.blue),
],
),
关于flutter - 禁用 TabBar flutter 中的滑动标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51518393/