且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Flutter中禁用开关选项卡

更新时间:2021-12-26 06:43:58

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