-2

i need a help to change color of title, when its selected. Now its blue, but i wanna change it to black. Here is my code

Widget build(BuildContext context) {
return Scaffold(
  body: Center(
    child: _widgetOptions.elementAt(_selectedIndex),
  ),
  bottomNavigationBar: BottomNavigationBar(
    items: <BottomNavigationBarItem> [
      BottomNavigationBarItem(  
        activeIcon: Icon(
          Icons.store,
          color: Colors.black,
        ),
        icon: Icon(
          Icons.store,        
          color: Colors.grey,    
        ),
        title: Text(
          'Ponuky',
          style: GoogleFonts.josefinSans(
            fontWeight: FontWeight.w600,
          ),
        ),
      ),
Marek
  • 201
  • 1
  • 4
  • 14

2 Answers2

0

title in BottomNavigationBarItem is deprecated right now, you have to use label instead of title and style it using properties.

How to style BottomNavigationBarItem label

Husen
  • 185
  • 1
  • 10
0

just add this two line after items closing bracket

selectedItemColor: Colors.black, unselectedItemColor: Colors.blue,

  bottomNavigationBar: BottomNavigationBar(
    items: <BottomNavigationBarItem> [
      BottomNavigationBarItem(  
        activeIcon: Icon(
          Icons.store,
          color: Colors.black,
        ),
        icon: Icon(
          Icons.store,        
          color: Colors.grey,    
        ),
        title: Text(
          'Ponuky',
          style: GoogleFonts.josefinSans(
            fontWeight: FontWeight.w600,
          ),
        ),
      ),],
      selectedItemColor: Colors.black,
      unselectedItemColor: Colors.blue,
safiya
  • 40
  • 2
  • 6