如何设置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
相关产品推荐
相关产品推荐

