Reputation: 905
Currently, I have a library in flutter https://pub.dev/packages/curved_navigation_bar and already implemented it in my project, but the problem is that when you navigating on item, icon color of selected item doesn't change. Is it possible to dynamically change icon color of selected item?
This is what by default:
And this is what I need:
Thanks!
Upvotes: 3
Views: 2543
Reputation: 1
Two Properties are there
Upvotes: 0
Reputation: 4110
Even if it is late i found a way to do it:
return Scaffold(
body: Stack(
children: [
_tabItems[_activePage],
Align(
alignment: Alignment.bottomCenter,
child: CurvedNavigationBar(//your stuff),
)
],
),
);
Upvotes: 0
Reputation: 4110
I think this should work.
class HomeBottomNavigationBar extends StatefulWidget {
@override
_HomeBottomNavigationBarState createState() =>_HomeBottomNavigationBarState();
}
class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar>
{
int pressedButtonNo = 0;
@override
Widget build(BuildContext context) {
return CurvedNavigationBar(
items: <Widget>[
Icon(Icons.add, size: 30, color: (pressedButtonNo = 0)? Colors.Green : Colors.Black,),
Icon(Icons.list, size: 30, color: (pressedButtonNo = 1)? Colors.Green : Colors.Black,),
Icon(Icons.compare_arrows, size: 30, color: (pressedButtonNo = 2)? Colors.Green : Colors.Black,),
],
onTap: (index) {
setState () {
pressedButtonNo = index;
}
},
);
}}
I have not tested it. Hope it works! Happy Coding:)
Upvotes: 2