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),
],
);
}
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,
..........
Wrap your BottomNavigationBar inside Material widget and provide color property as
Material(
color: Colors.blue,
child:BottomNavigationBar(),
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With