title: Flutter Firestore query with no matching results results causes query to hang when using orderBy
body: <p>I am trying to query for products in a Firestore collection ordered by itemName. This all works fine and orders the documents correctly when there are documents that match the query.</p>
  
  <p>The problem arises when the query has no matching document and the orderBy is used, the query never seems to complete.</p>
  
  <p>This is my code:</p>
  
  <pre><code>CollectionReference products = Firestore.instance.collection('products');
  Query query;
  query = products.where('keywords', arrayContains: searchString);
  query = query.orderBy('itemName', descending: false);
  Stream resultsStream = query.snapshots();
  
  StreamBuilder&lt;Object&gt;(
     stream: resultsStream,
     builder: (BuildContext context, AsyncSnapshot snapshot) {
  
            if (!snapshot.hasData) {
              return Center(child: CircularProgressIndicator());
            } else {
                if (snapshot.data.documents.length &gt; 0) {
                    return ProductList(snapshot);
                } else {
                    return Center(child: Text('No items found'));
                }
            }
  </code></pre>
  
  <p>So if the searchString is something like 'kid' and it matches results everything is fine. If the searchString is 'aaaa' and doesn't match any results. The first if statement with <code>!snaspshot.hasdata</code> is always true and the snapshot never gets data. </p>
  
  <p>The weird thing is though if you remove the <code>query.orderBy</code> and get the query results that have no matching document it will get data and the <code>snapshot.hasData</code> will become `true,  it will then continue on to the next if statement and display the text 'No items found'.</p>
  
  <p>I am wondering whether there is another way to check if query completed or using <code>!snapshot.hasData</code>is not suitable in this instance.</p>
  
  <p>Thanks</p>