title: Flutter - Add new Widget on click
body: <p>I'm new to flutter and I'm trying to build a rather simple app.
  I have this simple (and still in progress) code and I'm trying to add a new Widget every time the user clicks a button.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>class ResponsavelProfilePage extends StatefulWidget {
    @override
    _ResponsavelProfilePageState createState() =&gt; new _ResponsavelProfilePageState();
  }
  
  class _ResponsavelProfilePageState extends State&lt;ResponsavelProfilePage&gt; {
  
    int _count = 1;
  
    @override
    Widget build(BuildContext context) {
      List&lt;Widget&gt; _contatos = new List.generate(_count, (int i) =&gt; new ContactRow());
  
      return new Scaffold(
          appBar: new AppBar(
            title: new Text(GlobalConstants.appName),
          ),
          body: new LayoutBuilder(builder: (context, constraint) {
            final _maxHeight = constraint.biggest.height / 3;
            final _biggerFont = TextStyle(fontSize: _maxHeight / 6);
  
            return new Center(
              child: new Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: &lt;Widget&gt;[
                  new TextFormField(
                    decoration: new InputDecoration(
                      labelText: 'Nome',
                    ),
                  ),
                  new Container(
                    padding: new EdgeInsets.all(20.0),
                  ),
                  new TextFormField(
                    decoration: new InputDecoration(
                      labelText: 'Data de nascimento',
                    ),
                  ),
                  new Container(
                    padding: new EdgeInsets.all(20.0),
                  ),
                  new Row(
                    children: _contatos,
                  ),
                  new FlatButton(
                      onPressed:  _addNewContactRow,
                    child: new Icon(Icons.add),
                  ),
                  //new ContactRow()
                ],
              ),
            );
          })
      );
    }
  
    void _addNewContactRow() {
      setState(() {
        _count = _count + 1;
      });
    }
  }
  
  class ContactRow extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; new _ContactRow();
  
  }
  
  class _ContactRow extends State&lt;ContactRow&gt; {
    @override
    Widget build(BuildContext context) {
      return new Container(
          child:
          new Column(
              children: &lt;Widget&gt;[
                new TextFormField(
                  decoration: new InputDecoration(
                    labelText: 'Contato',
                  ),
                ),
                new Text("Tipo Contato: "),
                new DropdownButton(
                  value: _currentContactType,
                  items: _dropDownMenuItems,
                  onChanged: changedDropDownItem,
                ),
                new Container(
                  padding: new EdgeInsets.all(20.0),
                ),
              ]
          )
      );
    }
  
    List _contactTypes =
    ["Phone (SMS)", "Phone (Whatsapp)", "Email"];
  
    List&lt;DropdownMenuItem&lt;String&gt;&gt; _dropDownMenuItems;
    String _currentContactType;
  
    @override
    void initState() {
      _dropDownMenuItems = getDropDownMenuItems();
      _currentContactType = null;
      super.initState();
    }
  
    List&lt;DropdownMenuItem&lt;String&gt;&gt; getDropDownMenuItems() {
      List&lt;DropdownMenuItem&lt;String&gt;&gt; items = new List();
      for (String city in _contactTypes) {
        items.add(new DropdownMenuItem(
            value: city,
            child: new Text(city)
        ));
      }
      return items;
    }
  
    void changedDropDownItem(String selectedCity) {
      setState(() {
        _currentContactType = selectedCity;
      });
    }
  }
  </code></pre>
  
  <p>I want to add another ContactRow when the user clicks that Flat Button with addNewContactRow() on onPressed.
  I've found the code on addNewContactRow() and the List.generate part on another question here, but I can't make it work.</p>
  
  <p>Can some one please help?</p>