title: Flutter: How to change variables through TextFormField in a AlertDialog?
body: <p>I want to implement a function as following:
  There is a button named <code>自定义</code>. In this page, there is a variable named <code>money</code>. When I click the button, an AlertDialog with a TextFormField inside will occur. I hope that after inputting a number X into the TextFormField and clicking button <code>ok</code> to exit the AlertDialog, <code>money</code> would be changed to X. I have used <code>onSaved</code> to save the variable, and used <code>_formkey.currentState.save()</code>, but <code>money</code> didn't change. What's wrong with my codes? Here are my codes:</p>
  <pre><code>void _showMessageDialog() {
      //int addMoney = 0;
      showDialog(
        context: context,
        builder: (BuildContext context) {
          // return object of type Dialog
          return AlertDialog(
            key: _formKey,
            title: new Text('INPUT'),
            content: TextFormField(
              maxLines: 1,
              keyboardType: TextInputType.emailAddress,
              autofocus: false,
              style: TextStyle(fontSize: 15),
              decoration: new InputDecoration(
                  border: InputBorder.none,
                  hintText: 'input',
              ),
              onSaved: (value) {
                money = int.parse(value?.trim() ?? '0') as double;
                print(money);
              }
            ),
            actions: &lt;Widget&gt;[
              new TextButton(
                key: _formKey,
                child: new Text(&quot;ok&quot;),
                onPressed: () {
                  _formKey.currentState?.save();
                  Navigator.of(context).pop();
                },
              ),
            ],
          );
        },
      );
    }
  </code></pre>
  <p>Here are the codes relative to the button <code>自定义</code></p>
  <pre><code>OutlinedButton(
                                  style: OutlinedButton.styleFrom(
                                    side: BorderSide(
                                      width: 1,
                                      color: Colors.blueAccent
                                    )
                                  ),
                                  onPressed: () {
                                    // Navigator.of(context).push(
                                    //   _showMessageDialog()
                                    // );
                                    _showMessageDialog();
                                  },
                                  child: Text(
                                    &quot;自定义&quot;,
                                    style: TextStyle(
                                      fontSize: 20,
                                      fontWeight: FontWeight.w700,
                                      color: Colors.blueAccent
                                    ),
                                  ),
                                ),
  </code></pre>
  <p>I know maybe I have made a big mistake, but it is my first Flutter project. Thanks for your advices.</p>