title: How to make one widget disappear when another widget is clicked?
body: <p>My page has two stateful widgets (say A and B). When A is clicked, I want to B to disappear and then A to occupy the full width of the screen. I cannot figure out how to make B disappear.</p>
  
  <p>A is expanded as expected but the presence of B is causing an overflow. I tried using ValueListenableBuilder to pass a variable which will then trigger the visibility of B to become false but couldn't implement it.</p>
  
  <pre><code>  @override
    Widget build(BuildContext context) {
      return MaterialApp(
          title: 'Flutter layout demo',
          home: Scaffold(
              return Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: &lt;Widget&gt;[HeadCardApp("Society", 'assets/houses.png', 1), //Widget A
                    HeadCardApp("Community",'assets/discuss.png', 2)], //Widget B
                ),
              ),
            );}
    }
  }
  class HeadCardApp extends StatefulWidget {
    final String heading;
    final String imgLink;
    final int stateNo;
    HeadCardApp(this.heading, this.imgLink, this.stateNo);
    @override
    HeadCard createState() =&gt; HeadCard(heading, imgLink, stateNo);
  }
  class HeadCard extends State&lt;HeadCardApp&gt; {
    String heading;
    String imgLink;
    double _width = 380;
    double _height = 180;
    int stateNo;
    HeadCard(this.heading, this.imgLink, this.stateNo);
    @override
    Widget build(BuildContext context) {
      return new GestureDetector(
        onTap: (){
          if(stateNo == 1){
   //Space to make changes
          }
          else
            {
  
            }
          setState(() {
              _width = MediaQuery.of(context).size.width;
              _height = MediaQuery.of(context).size.height;
          });
        },
      child: AnimatedContainer(
        width: _width,
        height: _height,
        duration: Duration(milliseconds: 500),
        curve: Curves.fastOutSlowIn,
  
  
        ),
      ));
    }
  }```
  </code></pre>