I want to change the background color of my bottom navigation bar to black but yet it’s remaining white. What could be causing the issue?
Screenshot of the bottom navigation bar
Bottom navigation bar code.
bottomNavigationBar: BottomNavigationBar(
onTap: _onItemTapped,
type: BottomNavigationBarType.shifting,
iconSize: 30,
unselectedItemColor: Colors.black,
selectedIconTheme: const IconThemeData(color: Colors.black, size: 30),
selectedItemColor: Colors.black,
selectedLabelStyle: const TextStyle(fontWeight: FontWeight.bold),
backgroundColor: Colors.white,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.door_back_door),
label: 'Rooms',
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: 'Search',
),
BottomNavigationBarItem(
icon: Icon(Icons.map),
label: 'Maps',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
),
],
currentIndex: _selectedIndex,
),
I’ve been trying to figure this part out and I can’t seem to see the reason of the issue. I’d appreciate any help if possible! 🙂
2
Answers
Read the description of the
BottomNavigationBar
backgroundColor
, it saysSo the solution can be to set
backgroundColor
to one of yourBottomNavigationItem
s and it will apply to the wholeBottomNavigationBar
.background color
works only when thetype
isBottomNavigationBarType.fixed
If
type
isBottomNavigationBarType.shifting
,items
will override thiscolor
BottomNavigationBarType.fixed
BottomNavigationBarType.shifting