title: Firestore collection query as stream in flutter
body: <p>I'm trying to query a few documents from a collection, this query should listen to changes made in the queried documents, so I'd need a stream. I'm doing following (in Dart/Flutter)</p>
  
  <pre><code>  Stream&lt;List&lt;MatchRequest&gt;&gt; _getNewMatches() {
      return Collection&lt;MatchRequest&gt;(path: 'requests')
          .ref
          .where('status', isNull: true)
          .where('users', arrayContains: ['$currentUid'])
          .orderBy('last_activity')
          .snapshots()
          .map((list) =&gt; list.documents.map(
              (doc) =&gt; Global.models[MatchRequest](doc.data) as MatchRequest));
    }
  </code></pre>
  
  <p><em>(The object Collection sets the path to the ref in it's constructor, eg: ref = db.collection($path) and the map makes a model of the results)</em></p>
  
  <p>Then I'm using a StreamBuilder with <code>stream</code> invoking the method above and <code>builder</code> checking if snapshot.hasData. But it keeps loading, snapshot.hasData keeps being false. What am I doing wrong here?</p>
  
  <p>EDIT:</p>
  
  <ol>
  <li><p>My firestore security rules contain:</p>
  
  <pre><code>match /requests/{requestId} {
      allow read: if isLoggedIn();
      allow write: if isLoggedIn();
  }
  </code></pre></li>
  <li><p>When removing every <code>where</code> and <code>orderBy</code>, it doesn't find anything as well. And there are documents present in the requests-collection </p></li>
  <li><p>When trying to query only 1 document as a stream from the requests-collection, he does find the result</p></li>
  <li><p>Is it because I should add indexes to my firestore indexes? But this won't solve my first problem which is that even without <code>where</code> and <code>orderBy</code>, it doesn't get any data</p></li>
  </ol>