title: Build function returns null in Flutter form validation
body: <p>I'm building a form with validation with Flutter and I face a problem. I'm quite surprised as I'm - for now - following official documentation. I have looked at many websites and my code looks similar, but I still get an error.</p>
  
  <p>My code:</p>
  
  <pre><code>class addObjectForm extends StatefulWidget {
    @override
    addObjectFormState createState() =&gt; addObjectFormState();
  }
  
  class addObjectFormState extends State&lt;addObjectForm&gt; {
    Widget build(BuildContext context) {
      final _formKey = GlobalKey&lt;FormState&gt;();
  
      @override
      Widget build(BuildContext context) {
        MyObject _insertedObject = MyObject();
  
        return Form(
            key: _formKey,
            child: Column(
              children: &lt;Widget&gt;[
                TextFormField(
                  decoration: InputDecoration(labelText: "Insert object name"),
                  keyboardType: TextInputType.text,
                  validator: (value) {
                    if (value.isEmpty) {
                      return 'Please insert a value';
                    }
                    return null;
                  },
                  onSaved: (value) =&gt; _insertedObject.objectName = value,
                ),
                RaisedButton(
                  child: Text("Add"),
                  onPressed: () {
                    if (_formKey.currentState.validate()) {
                      _formKey.currentState.save();
                      //To be changed to change state and save it into the global object list
                      Scaffold.of(context).showSnackBar(
                          SnackBar(content: Text('Object has been added')));
                    }
                  },
                )
              ],
            ));
      }
    }
  } //End of addObjectFormState
  </code></pre>
  
  <p>The error message (in the iOS simulator, not in VSCode):</p>
  
  <p><a href="https://i.stack.imgur.com/j2G7e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j2G7e.png" alt="Error message"></a></p>
  
  <p>Thank you !</p>