title: show/hide a widget without recreating it
body: <p>Let's say I have 2 cards and one is shown on screen at a time. I have a button that replaces the current card with other cards. Now assume that there is some data on card 1 and some data on card 2 and I don't want to destroy the data on each of them or I don't want to rebuild any of them again.  </p>
  
  <p>I tried using Stack Widget and overlapping one on top of others with a boolean on the top card. The value of this boolean is reversed by calling <code>setstate</code> when the button is pressed. The issue is as soon as I press the button, the new card rebuilds all over again and then shown or <code>initState</code> is called again, which I don't want. Any Solution?</p>
  
  <p>EDIT: Sample Code: </p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main() =&gt; runApp(new MyApp());
  
  class MyApp extends StatelessWidget {
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return new MaterialApp(
        title: 'Flutter Demo',
        theme: new ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: new MyHomePage(title: 'Flutter Demo Home Page'),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; new _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    var toggleFlag = false;
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
        ),
        body: new Center(
          child: toggleFlag
              ? CustomWidget(color: Colors.blue)
              : CustomWidget(color: Colors.red),
        ),
        floatingActionButton: new FloatingActionButton(
          onPressed: _toggleCard,
          tooltip: 'Increment',
          child: new Icon(Icons.add),
        ), // This trailing comma makes auto-formatting nicer for build methods.
      );
    }
  
    void _toggleCard() {
      setState(() {
        toggleFlag = !toggleFlag;
      });
    }
  }
  
  class CustomWidget extends StatefulWidget {
    var color;
  
    CustomWidget({this.color});
  
    @override
    State&lt;StatefulWidget&gt; createState() {
      return new MyState();
    }
  }
  
  class MyState extends State&lt;CustomWidget&gt; {
    @override   //I don't want this to be called again and again
    Widget build(BuildContext context) {  
      return new Container(
        height: 100.0,  
        width: 100.0,
        color: widget.color,
      );
    }
  }
  </code></pre>