我正在尝试更改BottomNavigation图标的选定颜色,但似乎只能更改文本颜色。请帮助:
当前,当选中时,文本颜色会变为黄色,但图标保持白色,我希望它也是黄色的,我已经尝试将非活动图标的图标颜色设置为灰色,就像标题一样,但没有效果。
以下是我的代码:
当前,当选中时,文本颜色会变为黄色,但图标保持白色,我希望它也是黄色的,我已经尝试将非活动图标的图标颜色设置为灰色,就像标题一样,但没有效果。
![enter image description here](https://istack.dev59.com/eMhF2.webp)
new Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.black,
splashColor: Colors.yellowAccent,
unselectedWidgetColor: Colors.green,
primaryColor: Colors.red,
textTheme: Theme.of(context).textTheme.copyWith(caption: new TextStyle(color: Colors.grey))
),
child: new BottomNavigationBar(
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: const Icon(Icons.add_shopping_cart, color: Colors.white,),
title: new Text("Services"),
),
new BottomNavigationBarItem(
icon: new Theme(
data: new ThemeData(
),
child: const Icon(Icons.calendar_today, color: Colors.white,)),
title: new Text("Appointment")
),
new BottomNavigationBarItem(
icon: const Icon(Icons.face, color: Colors.white,),
title: new Text("Profile")
)
],
currentIndex: index,
onTap: (int i){setState((){index = i;});},
fixedColor: Colors.yellowAccent,
type: BottomNavigationBarType.fixed,
),
)