简体   繁体   中英

BottomNavigationBarItem label not showing when selected in flutter

Here the code is:

 BottomNavigationBar(
  selectedLabelStyle: TextStyles.labelSelectedTextStyle,
  unselectedLabelStyle: TextStyles.labelUnSelectedTextStyle,)

Two different styles added for navigation items, but when selected the item label is not showing.

For this, add the colors separately like below:

  selectedLabelStyle: TextStyles.labelSelectedTextStyle,
  unselectedLabelStyle: TextStyles.labelUnSelectedTextStyle,
  selectedItemColor:  Colors.blue,
  unselectedItemColor:  Colors.red,

Maybe someone will face the same problem now. Currently class BottomNavigationBar has property showUnselectedLabels ,which equals to false by default. So to make your labels in BottomNavigationBarItem display, you need to set following property:

showUnselectedLabels: true,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM