title: SetState not updating dialog box
body: <p>I'm trying to make a form for a user to log in an expense, and I would like to get the category of that expense. I've created a Dropdown Button with the items and all, but I would like the user to be able to enter in a custom category. For this i've made a category called other and when the user clicks it, the dropdown Button is replaced by a TextField and an Icon Button, to show the Dropdown again if the user chooses to pick anothe category instead. Everything works fine except the Icon Button. It doesn't do anything, can someone please explain why to me?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class UserPage extends StatefulWidget {
    @override
    _UserPageState createState() =&gt; _UserPageState();
  }
  
  class _UserPageState extends State&lt;UserPage&gt; {
    List&lt;List&gt; categories = [
      ['food', Icon(Icons.fastfood)],
      ['clothing', Icon(Icons.shopping_basket)],
      ['electronics', Icon(Icons.computer)],
      ['accessories', Icon(Icons.blur_circular)],
      ['transportation', Icon(Icons.local_taxi)],
      ['gain', Icon(Icons.attach_money)],
      ['other', Icon(Icons.radio_button_unchecked)]
    ];
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          appBar: AppBar(
            title: Text('Add Purchase Dialog'),
          ),
          body: Center(
              child: IconButton(
            icon: Icon(Icons.add_circle),
            onPressed: () {
              createPurchase(context);
            },
          )));
    }
  
    void createPurchase(BuildContext context) {
      final _formKey = GlobalKey&lt;FormState&gt;();
      final priceController = TextEditingController();
      final otherCategoryController = TextEditingController();
  
      var _selectedCategory;
      bool otherSelected = false;
      double dialogHeight = 187;
  
      List&lt;DropdownMenuItem&gt; menuItems = [];
      for (var category in categories) {
        menuItems.add(DropdownMenuItem(
            value: (category[0] != 'other')
                ? category[0]
                : otherCategoryController.text,
            child: Row(
              children: &lt;Widget&gt;[
                category[1],
                SizedBox(width: 5),
                Text(category[0]),
              ],
            )));
      }
  
      showDialog(
          context: context,
          builder: (context) =&gt; Dialog(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(20.0)),
                child: StatefulBuilder(
                  builder: (BuildContext context, StateSetter setState) {
                    return Container(
                      padding: EdgeInsets.fromLTRB(20, 10, 20, 0),
                      height: dialogHeight,
                      width: 300,
                      child: Column(
                        children: &lt;Widget&gt;[
                          Text('Add a purchase'),
                          Form(
                            key: _formKey,
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: &lt;Widget&gt;[
                                otherSelected
                                    ? Row(
                                        children: &lt;Widget&gt;[
                                          SizedBox(
                                              width: 184,
                                              height: 20,
                                              child: TextFormField(
                                                controller:
                                                    otherCategoryController,
                                                decoration: InputDecoration(
                                                    hintText: 'Other Category'),
                                              )),
                                          IconButton(
                                              icon: Icon(Icons.arrow_drop_down),
                                              onPressed: () {
                                                setState() =&gt; otherSelected =
                                                    !otherSelected;
                                              })
                                        ],
                                      )
                                    : DropdownButtonFormField(
                                        hint: Text('Category'),
                                        items: menuItems,
                                        onChanged: (category) =&gt; setState(() {
                                          _selectedCategory = category;
                                          (category == 'other')
                                              ? otherSelected = true
                                              : null;
                                        }),
                                        value: _selectedCategory,
                                        validator: (val) =&gt; (val == null)
                                            ? 'Select a category'
                                            : null,
                                      ),
                                TextFormField(
                                  decoration: InputDecoration(hintText: 'Amount'),
                                  controller: priceController,
                                  keyboardType: TextInputType.number,
                                  validator: (val) =&gt;
                                      (val == null) ? 'enter an amount' : null,
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  children: &lt;Widget&gt;[
                                    FlatButton(
                                        child: Text('Continue'), onPressed: null),
                                  ],
                                ),
                              ],
                            ),
                          )
                        ],
                      ),
                    );
                  },
                ),
              ));
    }
  }
  </code></pre>
  
  <p>I'd really appreciate some help, thanks.</p>