title: Flutter Form: The method 'validate' was called on null. [All configurations are already configured]
body: <p>please help me! I am creating simple login page but I got an exception look like this:</p>
  
  <blockquote>
    <p>══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY╞════════════════ [+3s] 
    I/flutter (11275): The following NoSuchMethodError was thrown
    building LoginScreen(dirty, dependencies: [MediaQuery]): [        ]
    I/flutter (11275): The method 'validate' was called on null. [<br>
    ] I/flutter (11275): Receiver: null [        ] I/flutter (11275):
    Tried calling: validate() [        ] I/flutter (11275):  [        ]
    I/flutter (11275): The relevant error-causing widget was: [        ]
    I/flutter (11275):   LoginScreen</p>
  </blockquote>
  
  <p>Although I think, I already configured all need configures. But somehow, My code thrown exception. How to fix it?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter_icons/flutter_icons.dart';
  import 'package:my_app/services/UserService.dart';
  
  /*
   * This is login screen view.
   * 
   * If you want to edit form section for example email and password fields, just edit these below functions.
   * - _formEmailWidget()
   * - _formPasswordWidget()
   * If you want to edit social login section, just edit _socialLoginWidget() function.
   * If you want to edit or change logo, just edit _logoWidget() function.
   */
  class LoginScreen extends StatelessWidget {
    static final Pattern _pattern =
        r'^(([^&lt;&gt;()[\]\\.,;:\s@\"]+(\.[^&lt;&gt;()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
    final GlobalKey&lt;FormState&gt; _key = GlobalKey&lt;FormState&gt;();
    final TextEditingController _emailController = TextEditingController();
    final TextEditingController _passwordController = TextEditingController();
  
    final UserAuth _auth = UserAuth.instance();
  
    final Status status;
  
    LoginScreen({@required this.status});
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          resizeToAvoidBottomPadding: false,
          body: SafeArea(child: this._bodyWidgets(context)));
    }
  
    _logoWidget() {
      return Padding(
          padding: const EdgeInsets.only(top: 15.0, bottom: 50.0),
          child: Image(image: AssetImage('assets/images/logo.png')));
    }
  
    _formEmailWidget() {
      return Container(
          decoration: BoxDecoration(
              border:
                  Border(bottom: BorderSide(color: Colors.white, width: 1.0))),
          child: TextFormField(
            controller: _emailController,
            keyboardType: TextInputType.emailAddress,
            validator: (String value) {
              RegExp regex = new RegExp(_pattern);
              if (regex.hasMatch(value)) {
                return null;
              }
              return "Please, Enter valid e-mail";
            },
            decoration: const InputDecoration(
                icon: Icon(
                  FontAwesome.user,
                  color: Colors.white,
                ),
                fillColor: Colors.white,
                hintStyle: TextStyle(
                  color: Colors.white,
                  fontFamily: 'ProximaThin',
                ),
                hintText: 'Your e-mail'),
          ));
    }
  
    _formPasswordWidget() {
      return Container(
          decoration: BoxDecoration(
              border:
                  Border(bottom: BorderSide(color: Colors.white, width: 1.0))),
          child: TextFormField(
            controller: _passwordController,
            validator: (String value) {
              if (value.isEmpty || value.length &lt; 6) {
                return "Password must be more than 6 characters";
              }
              return null;
            },
            decoration: const InputDecoration(
                icon: Icon(
                  FontAwesome.key,
                  color: Colors.white,
                ),
                fillColor: Colors.white,
                hintStyle: TextStyle(
                  color: Colors.white,
                  fontFamily: 'ProximaThin',
                ),
                hintText: 'Your password'),
            obscureText: true,
          ));
    }
  
    _submitRowWidget() {
      return Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: &lt;Widget&gt;[
          InkWell(
            onTap: null,
            child: Text(
              'forget password?',
              style: TextStyle(color: Colors.white),
            ),
          ),
          OutlineButton(
            textColor: Colors.white,
            highlightedBorderColor: Colors.white,
            borderSide: BorderSide(
                color: Colors.white, width: 0.8, style: BorderStyle.solid),
            shape: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
            onPressed: _loginAction(),
            child: Text(
              'Login',
              style: TextStyle(color: Colors.white),
            ),
          )
        ],
      );
    }
  
    _loginAction() {
      if (_key.currentState.validate()) {
        _auth.signIn(_emailController.text, _passwordController.text);
      } else {
        AlertDialog(
          content: Text(
              "Your e-mail or password doesn't match, Would you like create an account?"),
          elevation: 24.0,
          shape: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
          actions: &lt;Widget&gt;[
            FlatButton(
              onPressed: null,
              child: Text("Yes"),
            )
          ],
        );
      }
    }
  
    _socialLoginWidget() {
      return Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: &lt;Widget&gt;[
          Container(
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10)),
            ),
            child: FlatButton(
              padding: const EdgeInsets.only(
                  left: 10.0, top: 0.0, bottom: 0.0, right: 10.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: &lt;Widget&gt;[
                  Icon(FontAwesome.facebook_f, color: Colors.black),
                  SizedBox(
                    width: 10,
                  ),
                  Text('Facebook',
                      style: TextStyle(
                          fontFamily: 'Proxima',
                          fontSize: 11,
                          color: Colors.black))
                ],
              ),
              onPressed: null,
            ),
          ),
          Container(
            width: 100,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10)),
            ),
            child: FlatButton(
              padding: const EdgeInsets.only(
                  left: 10.0, top: 0.0, bottom: 0.0, right: 10.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: &lt;Widget&gt;[
                  Icon(
                    FontAwesome.google,
                    color: Colors.black,
                  ),
                  SizedBox(
                    width: 10,
                  ),
                  Text(
                    'Google',
                    style: TextStyle(
                        fontFamily: 'Proxima', fontSize: 11, color: Colors.black),
                  )
                ],
              ),
              onPressed: null,
            ),
          )
        ],
      );
    }
  
    _bodyWidgets(BuildContext context) {
      return Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: &lt;Widget&gt;[
            _logoWidget(),
            Expanded(
                child: Center(
              child: Container(
                width: MediaQuery.of(context).size.width - 20,
                decoration: BoxDecoration(
                    color: Colors.black,
                    boxShadow: [
                      BoxShadow(
                          color: Color.fromRGBO(0, 0, 0, 0.35),
                          blurRadius: 15.0,
                          offset: Offset(0, -5))
                    ],
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(30),
                        topRight: Radius.circular(30))),
                child: Padding(
                  padding:
                      const EdgeInsets.only(top: 45.0, left: 45.0, right: 45.0),
                  child: Column(children: &lt;Widget&gt;[
                    Form(
                      key: this._key,
                      child: Column(
                        children: &lt;Widget&gt;[
                          _formEmailWidget(),
                          _formPasswordWidget(),
                          SizedBox(
                            height: 15.0,
                          ),
                          _submitRowWidget()
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 45,
                    ),
                    Text('or connect using',
                        style: TextStyle(
                            fontFamily: 'ProximaThin', color: Colors.white)),
                    SizedBox(
                      height: 15,
                    ),
                    _socialLoginWidget(),
                    SizedBox(
                      height: 15,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: &lt;Widget&gt;[
                        Text(
                          'Don\'t have an account?',
                          style: TextStyle(
                              fontFamily: 'ProximaThin', color: Colors.white),
                        ),
                        SizedBox(
                          width: 5,
                        ),
                        InkWell(
                          onTap: null,
                          child: Text('Sign up',
                              style: TextStyle(
                                  fontFamily: 'Proxima', color: Colors.white)),
                        )
                      ],
                    )
                  ]),
                ),
              ),
            ))
          ]);
    }
  }
  </code></pre>