Set State not working in bottom navigation bar item even after using setState for 4 elements

int _currentIndex = 0;

    void onTabTapped(int index) {
      setState(() {
        _currentIndex = index;
      });
    }

@override
  Widget build(BuildContext context) {
    User user = FirebaseAuth.instance.currentUser;

    

    final List<Widget> _children = [
      CategoryScreen(email: user.email),
      TabBarOrder(),
      PayInScreen(),
      ProfileScreen(),
    ];

    return Scaffold(
      body: _children.elementAt(_currentIndex),
      bottomNavigationBar: BottomNavigationBar(
        showSelectedLabels: true,
        onTap: onTabTapped,
        currentIndex: _currentIndex,
        type: BottomNavigationBarType.fixed,
        iconSize: 0,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Menu'),
          BottomNavigationBarItem(icon: Icon(Icons.mail), label: 'Order'),
          BottomNavigationBarItem(
              icon: Icon(Icons.play_circle_filled), label: 'Pay-in'),
          BottomNavigationBarItem(
              icon: Icon(Icons.play_circle_filled), label: 'Profile'),
        ],
      ),
    );
 }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top