title: Form validation in flutter passes despite not meeting conditions
body: <p>I am building a Flutter application with multiple TextFormFields. I create a reusable TextFormfield Widget to keep things modular. The problem is, when the submit button is clicked, even though the Text Form Fields are not valid, it runs like it is valid.</p>
  <p>My TextFormField widget:</p>
  <pre><code>class AndroidTextField extends StatelessWidget {
    final ValueChanged&lt;String&gt; onChanged;
    final String Function(String?)? validator;
    const AndroidTextField(
        {Key? key,
        required this.onChanged,
        this.validator})
        : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      Size size = MediaQuery.of(context).size;
      return Container(
        width: size.width * .9,
        child: TextFormField(
          validator: validator,
          onChanged: onChanged,
      );
    }
  }
  </code></pre>
  <p>How I use it in the Scaffold</p>
  <pre><code>                        AndroidTextField(
                              validator: (value) {
                                if (value == null || value.isEmpty) {
                                  return 'Enter a valid name';
                                }
                                return '';
                              },
                              onChanged: (val) {
                                setState(() {
                                  lastName = val;
                                });
                              }),
  </code></pre>
  <p>The form</p>
  <pre><code>  final _formKey = GlobalKey&lt;FormState&gt;();
    @override
     Widget build(BuildContext context) {
      return Scaffold(
       body: Form(
          key: _formKey, 
          AndroidTextField(
              validator: (value) {
                 if (value == null || value.isEmpty) {
                 return 'Enter a valid name';
                 }
                 return '';
            },
              onChanged: (val) {
              setState(() {
              firstName = val;
              });
              }),
  
         TextButton(
           child: Text('Press),
           onPressed:(){
              if (_formKey.currentState!.validate()){
                    //do something
              }else{
                   //don't do the something
              }
  
          }
        ));
  
       }
  </code></pre>