I am using the bottom navigation bar in my project.
After coming on the Home screen error is showing:
Failed assertion: line 3634 pos 18: '!keyReservation.contains(key)': is not true.
I tried 2-3 ways to solve this bug but can't able to solve it.
I put a key in every scaffold screen of pages but was not able to solve it.
class Home extends StatefulWidget {
@OverRide
_HomeState createState() => new _HomeState();
}
class _HomeState extends State {
late List pages = [ MyOrders(), new HomeScreen(), CartItems() ];
int _selectedIndex = 1;
_onItemTapped(dynamic index) {
setState(() {
_selectedIndex = index;
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.monetization_on_outlined),
label: 'My Orders',
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle_outlined),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.work_outline),
label: 'My Cart',
),
],
currentIndex: _selectedIndex,
selectedItemColor: Color(0xff232869),
onTap: _onItemTapped,
),
body: pages[_selectedIndex],
) ;
}
}