title: Flutter not updating DropdownButton placed within a dialog when item is selected
body: <p>I have an alertDialog containing a DropdownButton widget. Whenever I click on an option within the dropDown I want it to display the selected value. I have listed the code below along with 2 screenshots.</p>
  <p>I believe this may be an issue with how flutter builds widget because when I placed the DropdownButton widget outside of the dialog it worked, however placing it within an alertDialog causes it to fail. I also noticed that if I clicked on an option in the DropdownButton and then exited and clicked on the dialog again the selected item would change. However, I want the selected value to change without the user having to tap out of the dialog and then back in.</p>
  <p><a href="https://i.stack.imgur.com/ivMkD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ivMkD.png" alt="enter image description here" /></a></p>
  <p>^</p>
  <p>The above image is the dialog when a user first clicks on it. At first the only selected item is &quot;I'm not able to help&quot;. This value should change whenever a user clicks on the DropdownMenu widget and selects a different option such as &quot;other&quot;.</p>
  <p><a href="https://i.stack.imgur.com/HfMKB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HfMKB.png" alt="enter image description here" /></a></p>
  <p>^</p>
  <p>These are the various options a user can click on within the dropdown menu. When a user clicks on it, the menu should update accordingly.</p>
  <p><strong>CODE:</strong></p>
  <p><em>Please note that I have defined _chosenValue as a global variable outside of the build function.</em></p>
  <pre><code>void _showDecline() {
  
        showDialog(
          context: context,
          builder: (BuildContext context) {
  
            return AlertDialog(
              title: new Text(&quot;Decline Appointment Request&quot;),
              content: Container(
                height: 100,
                width: 200,
                child: Column(
                  children: &lt;Widget&gt;[
                    new Text(&quot;Please select an option for why you declined.&quot;),
                    new DropdownButton&lt;String&gt;(
                      value: _chosenValue,
                      underline: Container(),
                      items: &lt;String&gt;['I\'m not able to help', 'Unclear description', 'Not available at set date and time', 'Other'].map((String value) {
                        return new DropdownMenuItem&lt;String&gt;(
                          value: value,
                          child: new Text(value, style: TextStyle(fontWeight: FontWeight.w500),),
                        );
                      }).toList(),
                       onChanged: (String value) {
                         setState(() {
                          _chosenValue = value;
                        });
                      },
                    )
                  ],
                ),
              ),
              actions: &lt;Widget&gt;[
                // usually buttons at the bottom of the dialog
                new FlatButton(
                  child: new Text(&quot;Close&quot;),
                  onPressed: () {},
                  },
                ),
                
              ],
            );
          },
        );
      }
  </code></pre>