Flutter 如何禁用tabBarView的滑动

Flutter 如何禁用tabBarView的滑动,flutter,Flutter,我有TabBar和TabBarView 基于我从服务器获取的数据,我想在其中一个选项卡上禁用 _tabController = TabController(vsync: this, length: 3, initialIndex: 0) ..addListener(() { print(_tabController.index); if (_album != null && (_album['descriptio

我有TabBar和TabBarView 基于我从服务器获取的数据,我想在其中一个选项卡上禁用

_tabController = TabController(vsync: this, length: 3, initialIndex: 0)
      ..addListener(() {
        print(_tabController.index);
        if (_album != null &&
            (_album['description'] == null ||
                _album['description'].toString().isEmpty) &&
            _tabController.index == 2) {
          setState(() {
            _tabController.index = 1;
            //it must be last tabController.index but I don't know how to impelement
          });
        }
      });
如果我们点击一个标签,它不会移动,而且每件事都是正确的

但是如果我们切换到第三个页面,它会有一个奇怪的行为,因为tabbar视图没有被禁用


那么我们如何解决刷卡问题呢?

您可以添加物理:NeverScrollableScrollPhysics(),如以下示例所示

TabBarView(
        physics: NeverScrollableScrollPhysics(),
        controller: tabcontroler,
        children: <Widget>[
          Container(color: Colors.red),
          Container(color: Colors.green),
          Container(color: Colors.blue),
        ],
      ),
TabBarView(
物理学:NeverscrollableScroll物理学(),
控制器:选项卡控制器,
儿童:[
容器(颜色:颜色。红色),
容器(颜色:颜色。绿色),
容器(颜色:颜色。蓝色),
],
),
完整参考