如何更改 Flutter 中 BottomNavigationBarItem 中标签的颜色?

alX*_*X-U 7 dart flutter

我正在应用程序的菜单中放置一些底部导航栏项目,我希望它们有一些标签。我贴了标签,但我真的不知道如何更改它们的基色。就像我希望他们都是白色的。

\n

这是其中之一的代码:

\n
bottomNavigationBar: BottomNavigationBar(\n      unselectedLabelStyle: const TextStyle(color: Colors.white, fontSize: 14),\n      backgroundColor: const Color(0xFF084A76),\n      fixedColor: Colors.white,\n      items: [\n        BottomNavigationBarItem(\n            icon: InkWell(\n              onTap: () async {\n                //Borramos un lote\n                deleteLote();\n              },\n              child: Container(\n                height: 47,\n                width: 50,\n                decoration: const BoxDecoration(\n                    shape: BoxShape.circle, color: Colors.black38),\n                child: const Icon(\n                  Icons.delete,\n                  size: 32,\n                  color: Colors.white,\n                ),\n              ),\n            ),\n            label: \'Borrar Lote\'),\n        BottomNavigationBarItem(\n            icon: InkWell(\n              onTap: () async {\n                //A\xc3\xb1adimos un lote\n                addLote();\n              },\n              child: Container(\n                height: 47,\n                width: 50,\n                decoration: const BoxDecoration(\n                    shape: BoxShape.circle, color: Colors.black38),\n                child: const Icon(\n                  Icons.add,\n                  size: 32,\n                  color: Colors.white,\n                ),\n              ),\n            ),\n            label: \'A\xc3\xb1adir Lote\')\n      ],\n    )\n
Run Code Online (Sandbox Code Playgroud)\n

现在的样子的图片,供参考:

\n

底部导航栏项目

\n

Eug*_*nko 9

您必须unselectedItemColor更改BottomNavigationBar.

bottomNavigationBar: BottomNavigationBar(
      unselectedLabelStyle: const TextStyle(color: Colors.white, fontSize: 14),
      backgroundColor: const Color(0xFF084A76),
      fixedColor: Colors.white,
      unselectedItemColor: Colors.white, //<-- add this
...
Run Code Online (Sandbox Code Playgroud)

更多详细信息:底部导航栏


小智 6

而是使用:

unselectedLabelStyle: const TextStyle(color: Colors.white, fontSize: 14),
Run Code Online (Sandbox Code Playgroud)

你可以试试 :

unselectedItemColor: Colors.white,
unselectedFontSize: 14,
Run Code Online (Sandbox Code Playgroud)

在你的底部导航栏中