title: how to display an error message if email and password is not valid in firebase flutter?
body: <p>i have developed an login page,if the email and password matches from the database it successfully login's and moves to the new page,but if its wrong i want to display an error message email or password doesn't match.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>class _AdminLoginState extends State&lt;AdminLogin&gt; {
    String _username, _password;
    TextEditingController _email = TextEditingController();
  
  
    final GlobalKey&lt;FormState&gt; _formkey = GlobalKey&lt;FormState&gt;();
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('LOGIN'),
          backgroundColor: Colors.indigo[900],
  
  
        ),
        body: SingleChildScrollView(
          child: Column(
            children: &lt;Widget&gt;[
              Container(
                padding: const EdgeInsets.only(top: 50),
                child: SizedBox(
                  height: 150.0,
                  width: 300,
                  child: Image.asset("assets/admin.png",
                    fit: BoxFit.contain,),
  
  
                ),
              ),
              Container(
  
                child: Text("ADMIN",style: TextStyle(fontSize: 15,fontWeight: FontWeight.bold,color: Colors.indigo),),
  
              ),
              Container(
                padding: const EdgeInsets.only(bottom: 50),
                child: Column(
                  children: &lt;Widget&gt;[
                    SingleChildScrollView(
  
                      child: Form(
                        key: _formkey,
                        child: Column(
                          children: &lt;Widget&gt;[
                            SizedBox(
                              height: 60,
                            ),
  
                            SizedBox(
                              width: 380,
                              height: 70,
                              child: Container(
                                padding: EdgeInsets.all(4),
                                width: 500,
                                height: 60,
                                child: TextFormField(
                                  autofocus: false,
                                  obscureText: false,
                                  keyboardType: TextInputType.emailAddress,
                                  validator:(input){
                                    if(input.isEmpty){
                                      return 'please type username';
                                    }
                                    return null;
                                  },
                                  onSaved: (input) =&gt; _username =input ,
                                  decoration: InputDecoration(
                                      labelText: 'Email',
                                      hintText: "Email",
                                      labelStyle: TextStyle(
                                        color: Colors.black,
                                        fontSize: 16,
                                      ),
                                    border: new OutlineInputBorder(
                                      borderRadius: const BorderRadius.all(
  
                                        const Radius.circular(20.0),
                                      ),
                                    ),
                                  ),
  
  
                                ),
                              ),
                            ),
  
                            SizedBox(
                              width: 380,
                              height: 70,
                              child: Container(
                                padding: EdgeInsets.all(4),
                                width: 400,
                                height: 60,
                                child: TextFormField(
                                  autofocus: false,
                                  obscureText: true,
                                  validator:(input){
                                    if(input.isEmpty){
                                      return 'please type Password';
                                    }
                                    return null;
                                  },
                                  onSaved: (input) =&gt; _password =input ,
                                  decoration: InputDecoration(
                                      labelText: 'Password',
                                      hintText: "Password",
                                      labelStyle: TextStyle(
                                        color: Colors.black,
                                        fontSize: 16,
                                      ),
                                    border: new OutlineInputBorder(
                                      borderRadius: const BorderRadius.all(
                                        const Radius.circular(20.0),
                                      ),
                                    ),
                                  ),
  
  
                                ),
                              ),
                            ),
                            Container(
                              padding: EdgeInsets.all(4),
                              width: 500,
                              height: 60,
                              child: RaisedButton(
                                onPressed: login,
                                textColor: Colors.white,
                                color: Colors.indigo[900],
                                child: Text('Login'),
                              ),
                            )
  
  
                          ],
                        ),
                      ),
                    ),
  
  
                  ],
  
  
                ),
              ),
  
            ],
  
          ),
        ),
        );
  
    }
    Future&lt;void&gt; login() async{
      final  formState = _formkey.currentState;
      if(formState.validate()){
        formState.save();
        try{
  
          final FirebaseUser user = (await FirebaseAuth.instance.signInWithEmailAndPassword(email: _username, password: _password)).user;
          Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; Admin()));
        }catch(e){
          print(e.message);
        }
  
  
      }
    }
  }
  </code></pre>
  
  <p>it will be really helpful if someone also helps me in validating the right email format and give give the proper validation for password</p>