title: How to make streambuilder await?
body: <p>I am build Flutter app with Firebase login but have issue with checking login status. On startup app must check if user logged in or not so it can show correct page. If logged in show homepage (different for different user role). If not, show login page.</p>
  <p>I am use <code>StreamBuilder</code> in RootPage of app for this but problem is app must first check user info with Firestore db so it know what type of user is logged in and then can route to correct page. Problem is I no find way to make <code>StreamBuilder</code> wait for this function to check user info before move on. So the conditionals which operate on the values returned by function are not evaluate correctly. Here is code:</p>
  <pre><code>    body: StreamBuilder&lt;FirebaseUser&gt;(
        stream: _auth.onAuthStateChanged,
        builder: (BuildContext context, snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return new SplashScreen();
          }
          if (snapshot.hasData &amp;&amp; getUserDetailsComplete == true) {
            _getUserDetails();
  
            if (isAdmin == true) {
              return new AdminScreen();
            } else if (isAdmin == false) {
              return new HomeScreen();
            }
          } else {
            return new RootPage();
          }
        },
      ),
    );
  }
  </code></pre>
  <p>You see I have make workaround for now by: 1. Return RootPage in else statement so it loop until one of conditionals is satisfied and 2. Set boolean to true when function _getUserDetails is complete and add to conditional so widget know when function is completed. But this make app startup slow and not good style.</p>
  <p>Anyone know better way to do?</p>