title: Exception caught by gestur
body: <p>i am making authentication form when i click on login button this error occur in console:</p>
  <pre class="lang-none prettyprint-override"><code>════════ Exception caught by gesture ═══════════════════════════════════════════
  The method 'trim' was called on null.
  Receiver: null
  Tried calling: trim()
  
  E/libPowerStretch( 2697): LucidStats currentFPS = 0.18 [2503977328]
  V/PhoneWindow( 2697): DecorView setVisiblity: visibility = 0, Parent = ViewRoot{cf969ce com.example.chad_cafe/com.example.chad_cafe.MainActivity,ident = 0}, this = DecorView@1192ed0[MainActivity]
  </code></pre>
  <pre><code>////import 'dart:ffi';
  
  import 'package:flutter/material.dart';
  
  class Authform extends StatefulWidget {
    Authform(this.submitFN, this.isLoading);
  
    final bool isLoading;
  
    final void Function(
      String email,
      String password,
      String username,
      bool isLogin,
      BuildContext ctx,
    ) submitFN;
  
    @override
    _AuthformState createState() =&gt; _AuthformState();
  }
  
  class _AuthformState extends State&lt;Authform&gt; {
    final _formKey = GlobalKey&lt;FormState&gt;();
  
    var _isLogin = true;
    var _userEmail;
    var _userName;
    var _userPassword;
  
    void _trySubmit() {
      final isValid = _formKey.currentState!.validate();
      FocusScope.of(context).unfocus();
      if (isValid) {
        _formKey.currentState!.save();
        widget.submitFN(_userEmail.trim(), _userPassword.trim(), _userName.trim(),
            _isLogin, context);
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return Center(
        child: Card(
          margin: EdgeInsets.all(20),
          child: SingleChildScrollView(
              child: Padding(
            padding: EdgeInsets.all(16),
            child: Form(
                key: _formKey,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    TextFormField(
                      key: ValueKey('email'),
                      validator: (value) {
                        if (value!.isEmpty || !value.contains('@')) {
                          return 'please enter valid email address';
                        }
                        return null;
                      },
                      keyboardType: TextInputType.emailAddress,
                      decoration: InputDecoration(
                          icon: Icon(
                            Icons.mail,
                            color: Colors.orange,
                          ),
                          labelText: 'Email Addess'),
                      onSaved: (value) {
                        _userEmail = value;
                      },
                    ),
                    if (!_isLogin)
                      TextFormField(
                        key: ValueKey('username'),
                        validator: (value) {
                          if (value!.isEmpty || value.length &lt; 4) {
                            return 'Username is short enter atleast 4 characters ';
                          }
                        },
                        decoration: InputDecoration(
                            icon: Icon(
                              Icons.person,
                              color: Colors.orange,
                            ),
                            labelText: 'Username'),
                        onSaved: (value) {
                          _userName = value;
                        },
                      ),
                    TextFormField(
                      key: ValueKey('password'),
                      validator: (value) {
                        if (value!.isEmpty || value.length &lt; 7) {
                          return 'Password must be atleast 7 characters long';
                        }
                        return null;
                      },
                      decoration: InputDecoration(
                        icon: Icon(
                          Icons.lock,
                          color: Colors.orange,
                        ),
                        labelText: 'password',
                      ),
                      obscureText: true,
                      onSaved: (value) {
                        _userPassword = value;
                      },
                    ),
                    SizedBox(
                      height: 12,
                    ),
                    if (widget.isLoading) CircularProgressIndicator(),
                    if (!widget.isLoading)
                      ElevatedButton(
                        onPressed: _trySubmit,
                        child: Text(_isLogin ? 'Login' : 'Signup'),
                        style: ElevatedButton.styleFrom(onPrimary: Colors.white),
                      ),
                    if (!widget.isLoading)
                      TextButton(
                          onPressed: () {
                            setState(() {
                              _isLogin = !_isLogin;
                            });
                          },
                          child: Text(_isLogin
                              ? 'Create new account'
                              : 'I already have a acoount'))
                  ],
                )),
          )),
        ),
      );
    }
  }
   
  
  
  
  ///import 'dart:html';
  
  import 'package:chad_cafe/Widgets/auths/auths_form.dart';
  import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:flutter/services.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  
  class AuthScreen extends StatefulWidget {
    @override
    _AuthScreenState createState() =&gt; _AuthScreenState();
  }
  
  class _AuthScreenState extends State&lt;AuthScreen&gt; {
    final _auth = FirebaseAuth.instance;
    var _isLoading = false;
  
    void _submitAuthForm(
      String email,
      String password,
      String username,
      bool isLogin,
      BuildContext ctx,
    ) async {
      UserCredential userCredential;
      try {
        setState(() {
          _isLoading = true;
        });
        if (isLogin) {
          userCredential = await _auth.signInWithEmailAndPassword(
              email: email, password: password);
        } else {
          userCredential = await _auth.createUserWithEmailAndPassword(
              email: email, password: password);
  
          await FirebaseFirestore.instance
              .collection('users')
              .doc(userCredential.user?.uid)
              .set({
            'username': username,
            'email': email,
          });
        }
      } on PlatformException catch (err) {
        var message = 'An error occured,Please check your Credentials';
        if (err.message != null) {
          message = err.message!;
        }
  
       /* Scaffold.of(ctx).showSnackBar(SnackBar(
          content: Text(message),
          backgroundColor: Theme.of(ctx).primaryColor,
        ));*/
        ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
        setState(() {
          _isLoading = false;
        });
      } catch (err) {
        print(err);
        setState(() {
          _isLoading = false;
        });
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          backgroundColor: Theme.of(context).primaryColor,
          body: Authform(
            _submitAuthForm,
            _isLoading,
          ));
    }
  }
  </code></pre>