flutter - 如何更改底部导航栏的颜色?
问题描述
如何更改 a 的颜色bottomNavigationBar
?
下面是我的代码片段。我无法更改小部件的颜色。
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
currentIndex: currentIndex,
onTap: (selectedPosition) => onNavItemTapped(selectedPosition),
items: <BottomNavigationBarItem>[
widget.buildBottomNavigationBarItem(
context, 'Discover', Icons.home, false, 0),
widget.buildBottomNavigationBarItem(
context, 'Chats', Icons.chat, true, 1),
],
);
}
解决方案
请像这样使用:
bottomNavigationBar: new Theme(
data: Theme.of(context).copyWith(
// sets the background color of the `BottomNavigationBar`
canvasColor: Colors.red,
),
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
..........
推荐阅读
- python - Openpyxl在一列中合并具有相同值的单元格
- python - 如何绘制数据,x轴上的时间而不是日期时间
- c# - 从c#中的其他方法调用以下函数时如何传递函数参数
- javascript - highchart 热图类型错误:无法将未定义转换为对象
- json - Fetch SyntaxError: Unexpected token < in JSON at position 0
- angular - 错误类型错误:在 innerhtml 中解析脚本时无法读取未定义的属性“文档”
- ruby-on-rails - activeadmin 和动态存储访问器在新资源上失败
- java - 在jsp中按下按钮后如何在java中运行main方法?
- php - 创建按钮过滤器 wordpress 自定义主题
- google-chrome - 在 Puppeteer 中如何在控制台中捕获 Chrome 浏览器日志