flutter - 如何更改底部导航栏颤动的颜色?
问题描述
我想在选择时更改底部导航栏中的颜色。每个图标都有不同的颜色。我怎么做?
这是代码:
bottomNavigationBar: new TabBar(
tabs: [
Tab(
icon: new Icon(Icons.home),
),
Tab(
icon: new Icon(Icons.search),
),
Tab(
icon: new Icon(Icons.account_box),
),
Tab(
icon: new Icon(Icons.enhanced_encryption),
),
Tab(icon: new Icon(Icons.store),)
],
labelColor: Colors.black,
unselectedLabelColor: Colors.grey[500 ],
indicatorSize: TabBarIndicatorSize.tab,
indicatorPadding: EdgeInsets.all(5),
indicatorColor: Colors.red,
),
backgroundColor: Colors.white,
),
),
);
}
}
先感谢您
解决方案
One way to do this would be to create a boolean list that represents the tabs, when selecting a tab changes the boolean value for it, and in icon color use a binary to display the color!
Icon (
Icons.home,
color: checkSelected[0] ? Colors.yellow : Colors.grey,
),
希望这可以帮助!
推荐阅读
- c++ - 对 constexpr 函数的嵌套调用
- java - 排除文件过滤器
- python - python if else 理解两个列表
- swift - 如何从 Facebook 获取用户电子邮件 ID
- intellij-idea - 如何在 IntelliJ 的运行和文档工具窗口中打开新选项卡?
- mysql - Mysql在提供后从下一行开始选择接下来的1000行
- android - MPAndroidChart 如何将信息视图添加到轴?
- ios - 访问字典数组的嵌套数组
- javascript - 使用 axios POST 时出现错误
- ssl - 从 conda 提示符安装任何软件包时出现 SSL 错误