gpt4 book ai didi

flutter - 禁用 TabBar flutter 中的滑动标签

转载 作者:IT老高 更新时间:2023-10-28 12:29:46 27 4
gpt4 key购买 nike

您好,我在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com