title: Flutter - Dart: how to return a Text widget from my function correctly
body: <p>so my problem is that I'm trying to load a screen after logging in with an user (firebase auth), this works fine. When logged in, I'm matching the users id from firebase auth, with the same id in firebase cloud, such that I can retrieve the data field "work_title" and display it directly in a Text widget.</p>
  
  <p>So of what i can read off the internet, supposedly everything in the screen is drawn first, only then its possible to retrieve the auth id of the current user, thats why I'm using a futurebuilder.</p>
  
  <p>My question now: why can't I return the <code>return Text(sh.data['work_title'].toString());</code>-part ? I do enter this part of the code, however it only returns the <code>return Text("??");</code>-part. </p>
  
  <p>I've also attached an image of this.</p>
  
  <p>Thanks :)</p>
  
  <pre><code> Widget buildText2() {
      return FutureBuilder(
          future: FirebaseAuth.instance.currentUser(),
          builder: (context, AsyncSnapshot&lt;FirebaseUser&gt; snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
              return Center(
                child: Text("Loading ..."),
              );
            } else {
              if (snapshot.hasData) {
                print(snapshot.hasData); // prints true, so we enter this part:
                DocumentReference doc = Firestore.instance
                    .collection("user_profiles")
                    .document(snapshot.data.uid);
                doc.get().then((sh) {
                  if (sh.exists) {
                    print(sh.exists); // prints true, så vi enter here as well:
                    print(sh.data['work_title'].toString());
                    return Text(sh.data['work_title'].toString()); // &lt;-- I want to return this
                  }
                });
              }
            } return Text("??");
          });
    }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JbilJ.png" rel="nofollow noreferrer">A screenshot of the code</a></p>