title: How to save Flutter TextFormField user input to a value?
body: <p>I'm trying to learn Flutter and I'm confused.</p>
  <p>I want to make a super simple text form and a button. The user enters text into the form, clicks the button, and the text prints to the console. How hard could this be? :-)</p>
  <pre class="lang-java prettyprint-override"><code>import 'package:flutter/material.dart';
  import 'package:flutter/foundation.dart';
  
  void main() =&gt; runApp(const Kabbalah());
  
  class Kabbalah extends StatelessWidget {
    const Kabbalah({Key? key}) : super(key: key);
  
    static const String _title = 'Kabbalistic Numerology';
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: _title,
        home: Scaffold(
            appBar: AppBar(
              title: const Text(_title),
            ),
            body: const Center(
              child: const FullNameField(),
            )
        ),
      );
    }
  }
  
  class FullNameField extends StatefulWidget {
    const FullNameField({Key? key}) : super(key: key);
  
    @override
    State&lt;StatefulWidget&gt; createState() {
      return _FullNameState();
    }
  }
  
  class _FullNameState extends State&lt;FullNameField&gt; {
  
    @override
    Widget build(BuildContext context) {
  
      return Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: &lt;Widget&gt;[
          Container(
            padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
            child: TextFormField(
              decoration: const InputDecoration(
                border: UnderlineInputBorder(),
                labelText: 'Enter your full name (First Middle Last)',
              ),
              onSaved: (String? fullName) {
                debugPrint(fullName);
                // This optional block of code can be used to run
                // code when the user saves the form.
              },
            ),
          ),
          ElevatedButton(
            style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
            onPressed: () {
              debugPrint('Clicked!');
              setState(() {
                _FullNameState.save(); // &lt;-- problem is here
              });
            },
            child: const Text('Get Fortune'),
          ),
        ],
      );
    }
  }
  </code></pre>
  <p>My code makes a nice little form and an adorable button.</p>
  <p><a href="https://i.stack.imgur.com/V17QC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V17QC.png" alt="enter image description here" /></a></p>
  <p>When enter a name and click the button I see <code>Clicked!</code> in the console.</p>
  <p>My plan is that after the user clicks the button we save the form state. Then <code>onSaved()</code> will execute and print the entered text to the console.</p>
  <p>The problem seems to be in saving the form state after the user clicks the button. <code>_fullNameState.save();</code> doesn't work because <code>_fullNameState</code> doesn't have a <code>.save</code> member. Don't we get <code>.save</code> from extending <code>StatefulWidget</code>?</p>
  <p>Thanks in advance for your help.</p>