here code How can I change selectedLabelStyle and selectedItemColor when I press just route to another but did not change when I selected they can route to that page but still not change i think it is problem in setState but i can not fix I'm beginer TT
`
class NavigationBar1 extends StatefulWidget {
const NavigationBar1({Key? key}) : super(key: key);
@override
State<NavigationBar1> createState() => _NavigationBarState();
}
class _NavigationBarState extends State<NavigationBar1> {
int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
if (_selectedIndex == 0) {
Navigator.pushNamed(context, '/home');
} else if (_selectedIndex == 1) {
Navigator.pushNamed(context, '/foodRecommend');
}
});
}
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.recommend),
label: 'Suggest',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
),
],
currentIndex: _selectedIndex,
selectedLabelStyle: GoogleFonts.prompt(fontSize: 16),
onTap: _onItemTapped,
selectedItemColor: Colors.amber[800],
);
}
}
`
I tried to change in setState()
but they did not work at all and change