title: Flutter - how to access the value of a future inside a streambuilder, with Firebase Auth
body: <p>I am using Firebase Authentication for a subscription-based app that I am building and using cloud functions and custom claims, I am ensuring that the user can only log in if they have an active subscription.</p>
  <p>My app has a landing page, which checks to see if the user is logged in and if they are, they are taken to the app home page. If not, they are shown the login screen. This is the code for it:</p>
  <pre><code>class LandingPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      final auth = Provider.of&lt;AuthBase&gt;(context, listen: false);
      return StreamBuilder&lt;User?&gt;(
          stream: auth.authStateChanges(),
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.active) {
              User? user = snapshot.data;
              user?.reload();
              user = snapshot.data;
  
              if (user == null || user.emailVerified == false) {
                return SignInHomePage.create(context);
              }
              return Provider&lt;User?&gt;.value(
                value: user,
                child: DisclaimerAcceptanceHomeScreen(
                  userName: user.displayName,
                ),
              );
            } else {
              return Scaffold(
                body: Center(
                  child: PlatformCircularProgressIndicator(),
                ),
              );
            }
          });
    }
  }
  </code></pre>
  <p>This works perfectly to get the user data and show the relevant screen. The only problem is, I don't know how to add the user's subscription status to this, to ensure only a user with an active subscription will be directed to the app's home page. The subscription status custom claim is returned as a future. In theory I would want to use something like this:</p>
  <pre><code>  final idTokenResult =
        await FirebaseAuth.instance.currentUser?.getIdTokenResult(true);
  </code></pre>
  <p>and then:</p>
  <pre><code>idTokenResult?.claims!['status']
  </code></pre>
  <p>The ideal condition that would return a user to the login screen would be:</p>
  <pre><code>user == null || user.emailVerified == false || idTokenResult?.claims!['status'] != 'active'
  </code></pre>
  <p>This does work inside an async/await function but you'll see that my landing page is a stateless widget and is not asynchronous.</p>
  <p>How can I modify the landing page code, to allow me to get the Future 'status' custom claim value? I would appreciate any suggestions on this. Thank you!</p>