Flutter-如何在BottomNavigationBarItem中将TextStyle添加到标签?

时间:2020-10-30 12:40:19

标签: flutter dart

我的应用程序中有一个BottomNavigationBar(),但是在更新到Flutter 1.22之后,title参数已弃用。由于新标签仅接受String输入,因此我无法通过Text()小部件来传递自定义TextStyle。现在如何通过新更新实现这一目标?

BottomNavigationBarItem(icon: Icon(Icons.notifications), label: 'tickets'),
BottomNavigationBarItem(icon: Icon(CustomIcons.calendar), label: 'calendar'),
BottomNavigationBarItem(icon: Icon(CustomIcons.home), label: 'home'),
BottomNavigationBarItem(icon: Icon(CustomIcons.podcasts), label: 'microphone'),
BottomNavigationBarItem(icon: Icon(CustomIcons.search), label: 'search')

1 个答案:

答案 0 :(得分:2)

BottomNavigationBar(
   selectedLabelStyle: TextStyle(),//your text style
   unselectedLabelStyle: TextStyle(),// your text style
   items: [
     BottomNavigationBarItem(icon: Icon(Icons.notifications), label: 'tickets'),
     BottomNavigationBarItem(icon: Icon(CustomIcons.calendar), label: 'calendar'),
     BottomNavigationBarItem(icon: Icon(CustomIcons.home), label: 'home'),
     BottomNavigationBarItem(icon: Icon(CustomIcons.podcasts), label: 
     'microphone'),
     BottomNavigationBarItem(icon: Icon(CustomIcons.search), label: 'search'),
   ]
)
相关问题