title: How to get doc of a collection with specifc condition from cloud firestore
body: <p>I am using StreamBuilder to get only those docs from the articles collection which satisfies the condition. I used where clause but it is getting all docs and sorting them.
  (Note: I want only those docs which satisfy condition in where not all.)
  updated code detail: Used another streambuilder to get the ids from the following field in a doc of users collection.</p>
  <p>Here how am I doing it:</p>
  <pre><code>StreamBuilder&lt;DocumentSnapshot&gt;(
                      stream: FirebaseFirestore.instance
                          .collection('users')
                          .doc(profileScreenController.currentUser.uid)
                          .snapshots(),
                      builder: (context,
                          AsyncSnapshot&lt;DocumentSnapshot&gt; futureSnapShot) {
                        if (!futureSnapShot.hasData &amp;&amp;
                            futureSnapShot.data == null) {
                          return SizedBox();
                        }
                        DocumentSnapshot documentSnapshot =
                            futureSnapShot.data;
                        return Container(
                          height: screenHeight * 0.32,
                          child: StreamBuilder&lt;QuerySnapshot&gt;(
                            stream: FirebaseFirestore.instance
                                .collection('articles')
                                .where('userId',
                                    isEqualTo: documentSnapshot['following'])
                                .snapshots(),
                            builder: (context,
                                AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) {
                              print(documentSnapshot['following']);
                              if (!snapshot.hasData &amp;&amp;
                                  snapshot.data == null) {
                                return Center(
                                  child: Lottie.asset('assets/loading.json'),
                                );
                              }
                              if (snapshot.data.docs.length == 0) {
                                return Center(
                                  child: Column(
                                    mainAxisAlignment:
                                        MainAxisAlignment.center,
                                    children: [
                                      Lottie.asset('assets/no articles.json',
                                          height: 140),
                                      SizedBox(
                                        height: 10,
                                      ),
                                      Text(
                                        'No body yet',
                                        style: TextStyle(
                                          fontSize: 20,
                                          color: Theme.of(context)
                                              .textTheme
                                              .headline1
                                              .color,
                                          fontWeight: FontWeight.bold,
                                        ),
                                      ),
                                    ],
                                  ),
                                );
                              }
                              return ListView.builder(
                                  shrinkWrap: true,
                                  scrollDirection: Axis.horizontal,
                                  itemCount: snapshot.data.docs.length,
                                  padding: EdgeInsets.only(left: 15),
                                  itemBuilder: (context, index) {
                                    selectedIndex = index;
                                    DocumentSnapshot todaysArticles =
                                        snapshot.data.docs[index];
                                    return Container(
                                      width: screenWidth * 0.8,
                                      margin: EdgeInsets.only(right: 6),
                                      decoration: BoxDecoration(
                                        borderRadius:
                                            BorderRadius.circular(30),
                                      ),
                                      child: Text(todaysArticles.data() 
                                              ['title'],
                                          ),
                                    );
                                  });
                            },
                          ),
                        );
                      }),
  </code></pre>
  <p>Result: getting doc of both users but not only where username is Guman as my where said.
  <a href="https://i.stack.imgur.com/fnOxt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fnOxt.png" alt="enter image description here" /></a></p>
  <p>My database with 2 docs in articles collection:
  <a href="https://i.stack.imgur.com/1SDTg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1SDTg.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/1HHus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1HHus.png" alt="enter image description here" /></a></p>