title: Using GetX Bind Stream with Firebase Firestore
body: <p>I'm working with Streams, Firebase Firestore and GetX. I want to Stream data from the database without having to use Stream Builder.. because, I will be needing multiple Streams</p>
  <p>So. here's my controller</p>
  <pre><code>RxList&lt;PostModel&gt; viewPost = RxList&lt;PostModel&gt;([]);
  
    @override
    void onInit() {
      super.onInit();
      viewPost.bindStream(PostService.instance
          .getPostsByUser(FirebaseAuth.instance.currentUser!.uid));
  }
  </code></pre>
  <p>Here's my getPostByUser function, which a Stream that returns a list of post models</p>
  <pre><code>Stream&lt;List&lt;PostModel&gt;&gt; getPostsByUser(uid) {
      return FirebaseFirestore.instance
          .collection(&quot;problemPost&quot;).orderBy('timestamp', descending: true )
          .where(&quot;uid&quot;, isEqualTo: uid)
          .snapshots()
          .map(postListFromSnapshot);
    }
  </code></pre>
  <p>This function here takes in a snapshot that comes from getPostByUser, and it then returns a list of post models.</p>
  <pre><code>List&lt;PostModel&gt; postListFromSnapshot(QuerySnapshot snapshot) {
      return snapshot.docs.map((doc) {
        return PostModel(
           commentCount: (doc.data() as Map&lt;String,dynamic&gt;)[&quot;commentCount&quot;] ?? '',
          firstName: (doc.data() as Map&lt;String,dynamic&gt;)[&quot;firstName&quot;] ?? '',
          id: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;id&quot;] ?? '',
          lastName: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;lastName&quot;] ?? '',
          likes: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;likes&quot;] ?? [],
          problemPost: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;problemPost&quot;] ?? 'Why now?',
          profileImageUrl: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;profileImageUrl&quot;] ?? '',
          timestamp: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;timestamp&quot;] ?? 0,
          type: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;type&quot;] ?? 0,
          uid: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;uid&quot;] ?? '',
          voteFor: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;voteFor&quot;] ?? [],
          voteAgainst: (doc.data() as Map&lt;String,dynamic&gt; )[&quot;voteAgainst&quot;] ?? [],
  
        );
      }).toList();
    }
  </code></pre>
  <p>So now, here's the issue.. when I tried using it in a ListView Builder I got an empty list.</p>
  <pre><code>GetBuilder&lt;ProfileViewController&gt;(
                    init: ProfileViewController(),
                    builder: (r) =&gt; ListView.builder(
                      itemCount: r.viewPost.length,
                      shrinkWrap: true,
                      physics: NeverScrollableScrollPhysics(),
                      itemBuilder: (BuildContext context, int index) {
                        final userPost = r.viewPost[index];
  
                        return Text(userPost.firstName);
                             // the result here was empty
                      },
                    ),
                  ),
  </code></pre>
  <p>Here's also the post model class</p>
  <pre><code>class PostModel {
    final String commentCount;
    final String firstName;
    final String lastName;
    final String id;
    final List likes;
    final List voteFor;
    final List voteAgainst;
    final String problemPost;
    final String profileImageUrl;
    final int type;
    final Timestamp timestamp;
    final String uid;
  
    PostModel({
      required this.uid,
      required this.commentCount,
      required this.firstName,
      required this.lastName,
      required this.likes,
      required this.voteFor,
      required this.voteAgainst,
      required this.problemPost,
      required this.profileImageUrl,
      required this.type,
      required this.id,
      required this.timestamp,
    });
  </code></pre>