title: How to set state to another class ? - Flutter
body: <p>I want to change the value of an integer in another class and rebuild this class so the bottom navigation bar items will change according to the integer</p>
  <p>Here's the main class were the bottom navigation bar exists and the condition to hide or show the items :</p>
  <pre><code>class Home extends StatefulWidget { 
   static int showCard = 0;
  @override
   _HomeState createState() =&gt; _HomeState();
  }  
  
  @override
   Widget build(BuildContext context) {
   ...
  
  //the items to show and hide according to int showcard
   if (Home.showCard == 0)
                BottomNavigationBarItem(
                  icon: Icon(
                    Icons.person_outlined,
                  ),
                  title: Text(
                    'Profile',
                  ),
                ),
              if (Home.showCard != 0)
                BottomNavigationBarItem(
                  icon: Icon(Icons.settings),
                  title: Text(
                    'Settings',
                  ),
                )
  </code></pre>
  <p>And here's the second class where i want to change the value of showcard to hide the profile section ad show the setting , i'm calling set state with on pressed in this class it's changing the value but not rebuilding the main class :</p>
  <pre><code>class Homehome extends StatefulWidget {
  const Homehome({Key? key}) : super(key: key);
    @override
  _HomehomeState createState() =&gt; _HomehomeState();
  }   
    class _HomehomeState extends State&lt;Homehome&gt; {
     @override
    Widget build(BuildContext context) {
    ...
     child: RaisedButton(
                                    onPressed: () {
                                      setState(() {
                                        Home.showCard = 1;
                                      });
  
                                      Navigator.of(context)
                                          .push(MaterialPageRoute(
                                        builder: (context) =&gt; Green(),
                                      ));
                                    },
    
  </code></pre>
  <p>any suggestions ?</p>