Flutter TabBar下方白条隐藏

TabBar下划线产生原因

我们在设置AppBar的时候,常常用到TabBar做嵌套导航,但是由于tabbar自带下划线,会使得界面的设计不美观

这是由于我们在 MaterialApp里面的theme主题管理中开启了 useMaterial3: true ,这会导致TabBar组件样式出现下划线

Tabbar取消下划线

解决的方案有两种

方案一

Themedate里面将useMaterial3设置为false

theme: ThemeData(
            fontFamily: "PingFang",
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueGrey),
            useMaterial3: false,
          )

方案二

Themedate里面添加一个属性tabBarTheme ,内容为const TabBarTheme(dividerColor: Colors.transparent)

theme: ThemeData(
            fontFamily: "PingFang",
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueGrey),
            useMaterial3: true,
            // 去除TabBar底部线条
            tabBarTheme: const TabBarTheme(dividerColor: Colors.transparent),
          )

效果如下

版权声明:本文为博主作者:qianxiamuxin原创文章,版权归属原作者,如果侵权,请联系我们删除!

原文链接:https://blog.csdn.net/qianxiamuxin/article/details/134228740

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2024年4月1日
下一篇 2024年4月1日

相关推荐