skip to Main Content

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

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


  1. Read the description of the BottomNavigationBar backgroundColor, it says

    If [type] is [BottomNavigationBarType.shifting] and the [items] have
    [BottomNavigationBarItem.backgroundColor] set, the [items]’
    backgroundColor will splash and overwrite this color.

    So the solution can be to set backgroundColor to one of your BottomNavigationItems and it will apply to the whole BottomNavigationBar.

    Login or Signup to reply.
  2. background color works only when the type is BottomNavigationBarType.fixed

    If type is BottomNavigationBarType.shifting, items will override this color


    BottomNavigationBarType.fixed

    enter image description here

    BottomNavigationBarType.shifting

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search