You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何设置PersistentBottomNavBar首页Tab选中/未选中时圆圈背景为透明或白色

解决PersistentBottomNavBar首页Tab选中/未选中状态圆形背景色设置问题

你只需要在原有PersistentBottomNavBarItem配置中新增activeColorSecondary、inactiveColorSecondary两个参数即可,这两个参数分别控制选中、未选中状态下图标背后的圆形背景色:

PersistentBottomNavBarItem(
  icon: Image.asset(
    "assets/homeScreenImages/home_active.png",
  ),
  inactiveIcon: Image.asset(
    "assets/homeScreenImages/home_unactive.png",
  ),
  title: ("Home"),
  activeColorPrimary: Colors.orange[700],
  inactiveColorPrimary: Colors.grey,
  // 新增以下两行配置
  activeColorSecondary: Colors.white, // 选中时圆形背景为白色
  inactiveColorSecondary: Colors.transparent, // 未选中时圆形背景为透明
),
  • 如果你需要选中时背景透明、未选中时背景为白色,交换上面两个参数的赋值即可
  • 若配置后不生效,请先确认你使用的PersistentBottomNavBar的navBarStyle参数为支持圆形图标背景的样式(如STYLE_DEFAULT、STYLE_FLOATER等),部分无图标背景的极简样式不支持该参数配置

效果参考图:
底部导航效果参考图

内容的提问来源于stack exchange,提问作者Avdhesh Purohit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 08:24:03