【问题标题】:How to disabled switch tab in flutter如何在颤动中禁用切换选项卡
【发布时间】:2021-03-31 12:50:19
【问题描述】:

在我的帮助页面中,我有这个开关选项卡,但我想知道如何禁用它,以便当用户单击“趋势”一词时,它不会做任何事情。

我只想显示它现在的方式,无论用户点击哪里,但现在只要用户点击“趋势”一词,标签就会切换。

任何关于如何禁用它的帮助或建议将不胜感激。

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

【问题讨论】:

    标签: flutter user-interface dart flutter-layout flutter-animation


    【解决方案1】:

    试试这个添加空函数调用或 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',
              )
            ],
          ),
        );
      }
    

    【讨论】:

    • 您好,谢谢您,但仍然无法正常工作,并且仍在切换选项卡。还有什么建议吗? :(
    猜你喜欢
    • 2021-09-12
    • 2017-07-04
    • 2011-03-05
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 2013-07-21
    • 2019-07-12
    • 1970-01-01
    相关资源
    最近更新 更多