Flutter - Changing SVG icon color

Viewed 9306

I have a Flutter app, which has a BottomNavigationBar, and its icons are made in svg. When selecting an icon from that bar, only the text changes color, the svg icons remain the same color.

bottomNavigationBar: BottomNavigationBar(
        selectedItemColor: widget._colors.orange,
        unselectedItemColor: widget._colors.grey,
        items: _iconNavBar,
        currentIndex: _index,
        type: BottomNavigationBarType.fixed,
        onTap: onTap,
      ),

Example of how the BottomNavigationBarItem() is doing

BottomNavigationBarItem(
    icon: SvgPicture.asset(
      'svgs/home.svg',
    ),
    label: 'Home')
1 Answers

Just try to use activeIcon: in bottomBarItem and there put your default icon with color. Example:

BottomNavigationBarItem(
              label: 'label',
              icon: SvgPicture.asset(
                  iconPath,
              ),
              activeIcon: SvgPicture.asset(
                  iconPath,
                  color: Colors.blue,
              ),
            ),
Related