title: Error when searching Firebase database with Flutter - The getter 'documents' isn't defined for the type 'QuerySnapshot'
body: <p>I want to create a search functionality for my project to fetch data from firestore. I am trying to create a Flutter search that searches documents from Firebase, but I am getting the error below:</p>
  <blockquote>
  <p>The getter 'documents' isn't defined for the type 'QuerySnapshot'. Try importing the library that defines 'documents', correcting the name to the name of an existing getter, or defining a getter or field named 'documents'.</p>
  </blockquote>
  <pre><code>import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:flutter/material.dart';
  import 'package:nethouese/pages/views/service2/searchService.dart';
  class search extends StatefulWidget {
    @override
    _searchState createState() =&gt; _searchState();
  }
  
  class _searchState extends State&lt;search&gt; {
    TextEditingController _searchController= TextEditingController();
    var QueryResult=[];
    var tempsearchstore=[];
    @override
    void initialSearch(String value) {
      if(value.length==0){
        setState(() {
          QueryResult=[];
          tempsearchstore=[];
        });
      }
      var capitalizedValue=value.substring(0,1).toUpperCase()+value.substring(1);
      if(QueryResult.length==0&amp;&amp; value.length==1){
        SearchService().searchByName(value).then((QuerySnapshot docs){
  
          //Below are the two lines of code where the error is occurring.
  
          for(int i=0;i&lt;QuerySnapshot.documents.length)
            QueryResult.add(docs.documents[i].data);
        });
      }
  
    }
  Widget build(BuildContext context) {
      return Container(
        child: Column(
          children: [
            Text('serch bar'),
            TextField(
              onChanged: (value){
                initialSearch(value);
              },
              controller: _searchController,
              decoration: InputDecoration(
                prefixIcon: IconButton(
                  color: Colors.black,
                  icon: Icon(Icons.arrow_back),
                  iconSize: 20.0,
                  onPressed:(){
                    Navigator.of(context).pop();
                  },
                )
              ),
            )
          ],
        ),
      );
    }
  }
  </code></pre>
  <p>Below is a screenshot of the lines of code where the error is occuring:</p>
  <p><a href="https://i.stack.imgur.com/I7taO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I7taO.png" alt="enter image description here" /></a></p>
  <p>i also get the same Error even if i chaged  QuerySnapshot to DocumentSnapshot
  <a href="https://i.stack.imgur.com/a7GE1.png" rel="nofollow noreferrer">enter image description here</a></p>