如何在Flutter中禁用开关选项卡 [英] How to disabled switch tab in flutter

查看:104
本文介绍了如何在Flutter中禁用开关选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的帮助页面中,我具有此切换选项卡,但是我想知道如何禁用它,以便当用户单击单词"Trending"时,它不会执行任何操作.

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',
          )
        ],
      ),
    );
  }

推荐答案

尝试添加这种空函数调用或像这样的onTap为空

Try this adding empty function call or null onTap like this

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',
          )
        ],
      ),
    );
  }

这篇关于如何在Flutter中禁用开关选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆