title: Flutter custom FormField : validate and save methods are not called
body: <p>I am quite new to Flutter, and I am struggling a bit to create a custom Form Field. The issue is that neither the validator nor the onSaved method from my custom FormField are called. I really am clueless on why they get ignored when I trigger a <code>formKey.currentState.validate()</code> or <code>formKey.currentState.save()</code>.</p>
  
  <p>This is a pretty simple widget for now, with an input text and a button.
  The button will fetch the current location of the user, and update the text field with the current address.
  When the user inputs an address in the text field, it will fetch the location for that address on focus lost (I have also integration with Google Maps, but I simplified it to isolate the issue).</p>
  
  <p>Here is the constructor of my form field : </p>
  
  <pre><code>class LocationFormField extends FormField&lt;LocationData&gt; {
  
      LocationFormField(
            {FormFieldSetter&lt;LocationData&gt; onSaved,
            FormFieldValidator&lt;LocationData&gt; validator,
            LocationData initialValue,
            bool autovalidate = false})
            : super(
                  onSaved: onSaved,
                  validator: validator,
                  initialValue: initialValue,
                  autovalidate: autovalidate,
                  builder: (FormFieldState&lt;LocationData&gt; state) {
                    return state.build(state.context);
                  });
  
        @override
        FormFieldState&lt;LocationData&gt; createState() {
          return _LocationFormFieldState();
        }
  }
  </code></pre>
  
  <p>As I need to handle state in my custom FormField, I build it in the FormFieldState object. The location state is updated when the button is pressed :</p>
  
  <pre><code>class _LocationFormFieldState extends FormFieldState&lt;LocationData&gt; {
  
   @override
   Widget build(BuildContext context) {
      return Column(
        children: &lt;Widget&gt;[
          TextField(
            focusNode: _addressInputFocusNode,
            controller: _addressInputController,
            decoration: InputDecoration(labelText: 'Address'),
          ),
          SizedBox(height: 10.0),
          FlatButton(
            color: Colors.deepPurpleAccent,
            textColor: Colors.white,
            child: Text('Locate me !'),
            onPressed: _updateLocation,
          ),
        ],
      );
    }
  
    void _updateLocation() async {
      print('current value: ${this.value}');
        final double latitude = 45.632;
        final double longitude = 17.457;
        final String formattedAddress = await _getAddress(latitude, longitude);
        print(formattedAddress);
  
        if (formattedAddress != null) {
          final LocationData locationData = LocationData(
              address: formattedAddress,
              latitude: latitude,
              longitude: longitude);
  
            _addressInputController.text = locationData.address;
  
          // save data in form
          this.didChange(locationData);
          print('New location: ' + locationData.toString());
          print('current value: ${this.value}');
      }
    }
  </code></pre>
  
  <p>This is how I instantiate it in my app. Nothing special here; I put it in a Form with a form key. There is another TextFormField to verify that this one is working fine:</p>
  
  <p><strong>main.dart</strong></p>
  
  <pre><code>Widget _buildLocationField() {
          return LocationFormField(
            initialValue: null,
            validator: (LocationData value) {
              print('validator location');
              if (value.address == null || value.address.isEmpty) {
                return 'No valid location found';
              }
            },
            onSaved: (LocationData value) {
              print('location saved: $value');
              _formData['location'] = value;
            },
          ); // LocationFormField
        }
  
  @override
    Widget build(BuildContext context) {
      return Scaffold(
            appBar: AppBar(
              // Here we take the value from the MyHomePage object that was created by
              // the App.build method, and use it to set our appbar title.
              title: Text(widget.title),
            ),
            body: Center(
              // Center is a layout widget. It takes a single child and positions it
              // in the middle of the parent.
              child: Container(
                margin: EdgeInsets.all(10.0),
                child: Form(
                  key: _formKey,
                  child: SingleChildScrollView(
                    padding: EdgeInsets.symmetric(horizontal: targetPadding / 2),
                    child: Column(
                      children: &lt;Widget&gt;[
                        _buildTitleTextField(),
                        SizedBox(
                          height: 10.0,
                        ),
                        _buildLocationField(),
                        SizedBox(
                          height: 10.0,
                        ),
                        _buildSubmitButton(),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          );
        }
  </code></pre>
  
  <p>The submit method triggered by the form submit button will just try to validate then save the form.</p>
  
  <p>Just printing the data saved in the form:</p>
  
  <pre><code>void _submitForm() {
      print('formdata : $_formData');
  
      if (!_formKey.currentState.validate()) {
        return;
      }
      _formKey.currentState.save();
  
      print('formdata : $_formData');
  }
  </code></pre>
  
  <p>But <code>_formData['location']</code> always returns null, and the validator is never called (no 'validator location' or 'location saved' printed in logs).</p>
  
  <p>I created a sample repo to reproduce this issue. You can try running the project, click first on the Locate me ! button, then the Save button at <a href="https://github.com/manumura/flutter-location-form-field" rel="noreferrer">https://github.com/manumura/flutter-location-form-field</a></p>