title: Is there a way to use the results of a catch block inside a widget in Flutter
body: <p>I am building a flutter app with Firebase as the back end.
  I have created an AuthService class on a separate file and import and use the Auth functions inside the log in screen.</p>
  <p>This is my AuthService Class.</p>
  <pre><code>class AuthService {
    Future&lt;UserModel?&gt; signInWithEmailAndPassword(
        String email, String password) async {
      try {
        final cred = await _auth.signInWithEmailAndPassword(
            email: email, password: password);
  
        return _userFromFirebase(cred.user);
      } on auth.FirebaseAuthException catch (e) {
        print(e.toString());
        return null;
      }
    }
  }
  </code></pre>
  <p>In the sign in page, I initialize the function:</p>
  <pre><code>    final auth = Provider.of&lt;AuthService&gt;(context);
  </code></pre>
  <p>Then use it in an onPressed :</p>
  <pre><code>                          press: () async {
  
                              // SIGN IN WITH EMAIL AND PASSWORD
                              dynamic result =
                                  await auth.signInWithEmailAndPassword(
                                      email, password);
  
                              // IF SIGN IN FAILS
                              if (result == null) {
                                setState(() {
                                  errorSigningIn = 'Sign in error';
                                  //this is where I want to use the error response. 
                                });
                              }
                            },
  </code></pre>
  <p>I am stuck on using the error I catch in the signInWithEmailAndPassword function and assigning it to the errorSigningIn variable in the SignIn widget.</p>
  <p>I am new to this, please help.</p>
  <p>Thanks.</p>