I just need the the label in my BottomNavigationBarItem's but I cant find a way to remove them.
You can hide the labels with showSelectedLabels
and showUnselectedLabels
set to false but there are no equivalent for Icons.
Constructor:
BottomNavigationBar({
Key key,
@required this.items,
this.onTap,
this.currentIndex = 0,
this.elevation = 8.0,
BottomNavigationBarType type,
Color fixedColor,
this.backgroundColor,
this.iconSize = 24.0,
Color selectedItemColor,
this.unselectedItemColor,
this.selectedIconTheme = const IconThemeData(),
this.unselectedIconTheme = const IconThemeData(),
this.selectedFontSize = 14.0,
this.unselectedFontSize = 12.0,
this.selectedLabelStyle,
this.unselectedLabelStyle,
this.showSelectedLabels = true,
bool showUnselectedLabels,
})
A better way I think is to configure the BottomNavigationBar. Just add this line and it will work fine. No need to add lines to each item
selectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
unselectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
ex.
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Business',
),
],
currentIndex: _selectedIndex,
selectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
unselectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
selectedItemColor: Colors.amber[800],
onTap: _onItemTapped,