为什么我的unselectedLabelStyle对我不起作用?\n在这个 unselectedLabelStyle 中使用 textStyle 属性保存我的更改后,对我来说什么都不会改变:/
class _NavBarState extends State<NavBar> {\n int _selectedPage = 0;\n\n PageController pageController = PageController();\n\n @override\n Widget build(BuildContext context) {\n return Scaffold(\n body: PageView(\n controller: pageController,\n children: <Widget>[\n HomeScreen(),\n MapScreen(),\n SearchScreen(),\n AccountScreen(),\n ],\n ),\n bottomNavigationBar: BottomNavigationBar(\n type: BottomNavigationBarType.fixed,\n currentIndex: _selectedPage,\n backgroundColor: Colors.white,\n selectedIconTheme: IconThemeData(color: Colors.black, size: 32),\n // selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold),\n unselectedIconTheme: IconThemeData(size: 26, color: Colors.grey.shade300),\n unselectedLabelStyle: TextStyle(color: Colors.grey.shade300),//HEEEEEERRRRRRRRREEEEEE\n onTap: (int index) {\n setState(() {\n _selectedPage = index;\n });\n\n pageController.animateToPage(\n index,\n duration: Duration(milliseconds: 500),\n curve:\n Curves.easeInOutExpo, \n );\n },\n items: [\n BottomNavigationBarItem(\n icon: Icon(\n Icons.home,\n ),\n title: Text('G\xc5\x82\xc3\xb3wna', style: TextStyle(color: Colors.black))),\n BottomNavigationBarItem(\n icon: Icon(\n Icons.location_on,\n ),\n title: Text('Mapa', style: TextStyle(color: Colors.black))),\n BottomNavigationBarItem(\n icon: Icon(\n Icons.search,\n ),\n title: Text('Szukaj', style: TextStyle(color: Colors.black))),\n BottomNavigationBarItem(\n icon: Icon(\n Icons.person,\n ),\n title: Text('Konto', style: TextStyle(color: Colors.black)),\n ),\n ],\n ),\n );\n }\n\n @override\n void dispose() {\n pageController.dispose();\n super.dispose();\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n
您可以通过直接在标题中提供标题样式来重叠 textStyle,此外,您可以使用unselectedItemColor属性来更改未选择项目的颜色。
\n\nunselectedItemColor: Colors.grey,\nRun Code Online (Sandbox Code Playgroud)\n\n更改标题自
\n\n title: Text('G\xc5\x82\xc3\xb3wna', style: TextStyle(color: Colors.black))),\nRun Code Online (Sandbox Code Playgroud)\n\n到:
\n\n title: Text('G\xc5\x82\xc3\xb3wna')),\nRun Code Online (Sandbox Code Playgroud)\n\n此外,我认为你应该在 flutter sdk 中提交错误,因为它没有像你提到的那样按预期工作。
\n\n /// If [selectedLabelStyle.color] and [unselectedLabelStyle.color] values\n /// are non-null, they will be used instead of [selectedItemColor] and\n /// [unselectedItemColor].\nRun Code Online (Sandbox Code Playgroud)\n\n根据以下文档注释,如果您指定 unselectedLabelStyle 的颜色,那么它应该使用该颜色,但它没有使用它。
\n| 归档时间: |
|
| 查看次数: |
3129 次 |
| 最近记录: |