title: Firebase auth user information stream
body: <p>I have a profile page the shows the user his currently registered email and an edit icon that takes him to the page where he can edit the email.
  When the user changes the email successfully, he is returned to the previous page that showed him the registered email.</p>
  <p>I want the user to see the new email. But the user keeps seeing the old email until the page is reloaded.</p>
  <p>So my first thought was to naturally replace the FutureBuilder with StreamBuilder.
  I was not sure how to get a stream of the current user and not the future, so I used the only stream I know for FirebaseUser --&gt; onAuthStateChanged</p>
  <pre><code>  Widget buildEmail() {
      return StreamBuilder(
        stream: FirebaseAuth.instance.onAuthStateChanged,
        builder: (BuildContext context, AsyncSnapshot&lt;FirebaseUser&gt; snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting)
            return Center(
                child: SpinKitRing(
              color: Colors.white,
              size: 30,
            ));
          else if (snapshot.hasError)
            return Center(child: Text(snapshot.error));
          else {
            // final email = snapshot.data.data['email'];
            final email = snapshot.data.email;
            return Padding(
              padding: const EdgeInsets.only(left: 25.0),
              child: Text('$email', style: TextStyle(color: Colors.black)),
            );
          }
        },
      );
    }
  </code></pre>
  <p>This StreamBuilder behaves identically to the FutureBuilder I had before</p>
  <pre><code>  Widget buildEmail() {
      return FutureBuilder(
        future: FirebaseAuth.instance.currentUser(),
        builder: (BuildContext context, AsyncSnapshot&lt;FirebaseUser&gt; snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting)
            return Center(
                child: SpinKitRing(
              color: Colors.white,
              size: 30,
            ));
          else if (snapshot.hasError)
            return Center(child: Text(snapshot.error));
          else {
            // final email = snapshot.data.data['email'];
            final email = snapshot.data.email;
            return Padding(
              padding: const EdgeInsets.only(left: 25.0),
              child: Text('$email', style: TextStyle(color: Colors.black)),
            );
          }
        },
      );
    }
  }
  </code></pre>
  <p>So I looked into the documentation of onAuthStateChanged and it states:</p>
  <pre><code>  /// Receive [FirebaseUser] each time the user signIn or signOut
  </code></pre>
  <p>This lead me to check on my update email method and check if my user is being signed in again to the app.</p>
  <pre><code>static Future&lt;void&gt; updateEmail(String password, String newEmail, BuildContext context) async {
      final user = await CurrentUser.getCurrentUser();
      final ref = Firestore.instance.collection('users');
  
      try {
        AuthCredential credential = EmailAuthProvider.getCredential(email: user.email, password: password);
        AuthResult result = await user.reauthenticateWithCredential(credential);  // Sign in?
        result.user.updateEmail(newEmail);
        ref.document(user.uid).updateData({'email': newEmail});
        Navigator.of(context).pop();
        Fluttertoast.showToast(msg: 'Success!');
      } on PlatformException catch (error) {
        print(error);
        changeEmailErrorDialog(context, error: error.message);
      } catch (error) {
        print(error);
        changeEmailErrorDialog(context, error: error);
      }
    }
  </code></pre>
  <p>I think that I am signing in the user since this method prevents the <code>ERROR_REQUIRES_RECENT_LOGIN</code> exception</p>
  <pre><code>  AuthResult result = await user.reauthenticateWithCredential(credential);  // Sign in?
  </code></pre>
  <p>Am I doing something wrong?
  How can I get a stream of the user?
  The Firebase method for obtaining the current user returns a future</p>
  <pre><code>FirebaseAuth.instance.currentUser();
  </code></pre>
  <p>Shouldn't there be a stream version of this method?</p>