Style BottomNavigationBar in Flutter

前端 未结 9 658
醉话见心
醉话见心 2020-12-12 19:22

I am trying out Flutter and I am trying to change the colour of the BottomNavigationBar on the app but all I could achieve was change the colour of the Bo

9条回答
  •  死守一世寂寞
    2020-12-12 19:31

    can change by setting colors to backgroundColor property if type is fixed.

    BottomNavigationBar(
              backgroundColor: Colors.red,
              type: BottomNavigationBarType.fixed,
              items: [
                BottomNavigationBarItem(
                    icon:Icon(Icons.home, color: Color.fromARGB(255, 255, 255, 255)),
                    title: new Text('Home'),),
                BottomNavigationBarItem(
                    icon: Icon(Icons.work,color: Color.fromARGB(255, 255, 255, 255)),
                    title: new Text('Self Help'),),
                BottomNavigationBarItem(
                    icon:Icon(Icons.face, color: Color.fromARGB(255, 255, 255, 255)),
                    title: new Text('Profile'),),
              ]
            )
    

    If the type is shifting it will use color inside bottomNavigationBarItem.

    BottomNavigationBar(
              backgroundColor: Colors.red,
              type: BottomNavigationBarType.shifting,
              items: [
                BottomNavigationBarItem(
                    icon:Icon(Icons.home, color: Color.fromARGB(255, 255, 255, 255)),
                    title: new Text('Home'),
                    backgroundColor: Colors.red),
                BottomNavigationBarItem(
                    icon: Icon(Icons.work,color: Color.fromARGB(255, 255, 255, 255)),
                    title: new Text('Self Help'),
                    backgroundColor: Colors.blue),
                BottomNavigationBarItem(
                    icon:Icon(Icons.face, color: Color.fromARGB(255, 255, 255, 255)),
                    title: new Text('Profile'),
                    backgroundColor: Colors.amber),
              ]
    
            )
    

    You can see even though I have set backgroundColor property it does not apply that colors and the background color inside BottomNavigationBarItem widget will override that.

    Found from here

提交回复
热议问题