您好,我有一个选项卡栏处于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属性更改页面视图响应用户输入的方式来实现这一点.为了达到这个目的,我们有一个NeverScrollableScrollPhysics,所以只需将physics改成这样就可以了:

TabBarView(
        physics: NeverScrollableScrollPhysics(),
        controller: tabcontroler,
        children: <Widget>[
          Container(color: Colors.red),
          Container(color: Colors.green),
          Container(color: Colors.blue),
        ],
      ),

Flutter相关问答推荐

关闭视频通话,相机仍在运行!(Flutter WebRTC)

我有相关的下拉菜单Flutter Windows应用程序的问题

Flutter :在后台实现振动

Flutter /dart 列表.第一个子类列表中的Where()错误

在Flutter 中更改扩展瓷砖的高度

我怎样才能go 掉这个底部导航栏上的白色背景

无法应用插件com.chaquo.python

自定义类提供程序 Riverpod Flutter 中的可变变量

如何动态获取任何小部件的像素?

Flutter ListView 在调用 setState 后未更新

Flutter / 为什么当我点击我的图片时我的模型没有更新?

启动画面中的淡入淡出图像

忽略异步函数上的 context.mounted 访问 linting 错误是否安全?

Agora VideoCall 不显示远程视频网格

graphql_flutter 错误:非抽象类GraphQLWebSocketChannel缺少实现

如何流畅切换画面?

如何使用 Rrect 或类似工具在 flutter 中绘制梯形线?

SfCircularChart 周围的额外间距

更新未知文档 ID firebase\flutter 中的字段

如何将 pushNamed 与 Dismissible Widget 一起使用并查看背景透明第一页