Style BottomNavigationBar in Flutter

前端 未结 9 677
醉话见心
醉话见心 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条回答
  •  猫巷女王i
    2020-12-12 19:33

    Try wrapping your BottomNavigationBar in a Container then set its color.

    Example:

    @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: null,
          body: pages(),
          bottomNavigationBar:new Container(
            color: Colors.green,
            child: BottomNavigationBar(
              items: [
                BottomNavigationBarItem(
                    icon: const Icon(Icons.home),
                    title: Text("Home")
                ),
                BottomNavigationBarItem(
                    icon: const Icon(Icons.work),
                    title: Text("Self Help")
                ),
                BottomNavigationBarItem(
                    icon: const Icon(Icons.face),
                    title: Text("Profile")
                )
              ],
            currentIndex: index,
            onTap: (int i){setState((){index = i;});},
            fixedColor: Colors.white,
            ),
          );
        );
      };
    

提交回复
热议问题