Home > Net >  scroll_navigation in flutter
scroll_navigation in flutter

Time:02-22

I'm working on a flutter project and I used scroll_navigation but I want to change selectedItemColor and unselectedItemColor and I don't know how to change the color of the selected item in my scroll navigation.

@override
    Widget build(BuildContext context) {
      return ScrollNavigation(
        bodyStyle: NavigationBodyStyle(
          background: Colors.white,
          borderRadius: BorderRadius.horizontal(left: Radius.circular(20)),
          scrollDirection: Axis.vertical,
        ),
        barStyle: NavigationBarStyle(
          position: NavigationPosition.left,
          elevation: 0.0,
          background: Colors.white,
        ),
        pages: [
          Container(color: Colors.blue[100]),
          Container(color: Colors.green[100]),
          Container(color: Colors.purple[100]),
          Container(color: Colors.amber[100]),
          Container(color: Colors.deepOrange[100])
        ],
        items: const [
          ScrollNavigationItem(icon: Icon(Icons.camera)),
          ScrollNavigationItem(icon: Icon(Icons.chat)),
          ScrollNavigationItem(icon: Icon(Icons.favorite)),
          ScrollNavigationItem(icon: Icon(Icons.notifications)),
          ScrollNavigationItem(icon: Icon(Icons.home))
        ],
      );
    }

CodePudding user response:

You may set active and non-active colors via NavigationBarStyle like this:

barStyle: const NavigationBarStyle(
...
  activeColor: Colors.red,
  deactiveColor: Colors.yellow,
),
  • Related