In my app I am using a BottomNavigationBar
with icons and text for the items in it. In one of the items the text is too long and thus overflows. With the title
property of the BottomNavigationBarItem
I could easily control this with the overflow
property of a Text
widget. Now the title
property is deprecated and we have to use the label
property for the text, which is just a string and not a widget. Now I have to set the text overflow behavior differently, but I don't know how? I looked into both TextStyle
and ThemeData
widgets, but they do not seem to have properties that control text overflow. Is there a way to control text overflow while using the label
property in a BottomNavigationBarItem
?
PS: I know it is best to have no overflow at all, but custom color is translated in spanish to color personalizado and it seems like it cannot be any shorter.
The overflow I want and get using the title
property:
The overflow I get when using label
:
The code I am using right now with only one BottomNavigationBarItem
because they're all basically the same:
BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.help),
// label: getTranslated(context, "help"),
title: Text(
getTranslated(context, "help"),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: false,
),
),
],
type: BottomNavigationBarType.fixed,
selectedItemColor: bottomBarSelected,
unselectedItemColor: bottomBarUnselected,
selectedFontSize: 12.0,
unselectedFontSize: 12.0,
currentIndex: _selectedIndex,
onTap: _onItemTapped,
backgroundColor: secondaryColor,
)