简体   繁体   English

如何禁用 flutter 中的开关选项卡

[英]How to disabled switch tab in flutter

In my help page, I have this switch tab but I'm wondering how can I disabled it so that when a user click on the word "Trending", it will not do anything.在我的帮助页面中,我有这个开关选项卡,但我想知道如何禁用它,以便当用户单击“趋势”一词时,它不会做任何事情。

I just want to display the way it's right now no matter where the user click but right now the tab got switch when ever a user click on the the word "trending".我只想显示它现在的方式,无论用户点击哪里,但现在只要用户点击“趋势”这个词,标签就会切换。

Any help or suggestion on how I can disabled it will be really appreciated.任何有关如何禁用它的帮助或建议将不胜感激。

 Widget tabBarWidget() {
    return Container(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(1),
          border: Border.all(color: Colors.grey, width: 1)),
      child: TabBar(
        controller: TabController(length: 2, vsync: this),
        tabs: [
          Tab(
            text: 'Recommended',
          ),
          Tab(
            text: 'Trending',
          )
        ],
      ),
    );
  }

在此处输入图像描述

Try this adding empty function call or null onTap like this试试这个添加空的 function 调用或 null onTap 像这样

Widget tabBarWidget() {
    return Container(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(1),
          border: Border.all(color: Colors.grey, width: 1)),
      child: TabBar(
        controller: TabController(length: 2, vsync: this),
        onTap:(i){}, // or onTap: null,
        tabs: [
          Tab(
            text: 'Recommended',
          ),
          Tab(
            text: 'Trending',
          )
        ],
      ),
    );
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM