Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the colour of a bottomNavigationBar?

Tags:

flutter

How can I change the colour of a bottomNavigationBar?

Here below is a snippet of my code. I am unable to change the color of the widget.

@override
  Widget build(BuildContext context) {
    return BottomNavigationBar(

      currentIndex: currentIndex,
      onTap: (selectedPosition) => onNavItemTapped(selectedPosition),
      items: <BottomNavigationBarItem>[
        widget.buildBottomNavigationBarItem(
            context, 'Discover', Icons.home, false, 0),
        widget.buildBottomNavigationBarItem(
            context, 'Chats', Icons.chat, true, 1),
      ],
    );
  }
like image 580
sudipta borah Avatar asked Dec 24 '22 06:12

sudipta borah


2 Answers

Please use like this:

bottomNavigationBar: new Theme(
        data: Theme.of(context).copyWith(
          // sets the background color of the `BottomNavigationBar`
          canvasColor: Colors.red,
        ),
        child: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          ..........
like image 97
MUHAMMED IQBAL PA Avatar answered Jan 18 '23 18:01

MUHAMMED IQBAL PA


Wrap your BottomNavigationBar inside Material widget and provide color property as

Material(
        color: Colors.blue,
        child:BottomNavigationBar(),
);
like image 28
Dhiraj Sharma Avatar answered Jan 18 '23 19:01

Dhiraj Sharma