title: How to count the number of documents firestore on flutter?
body: <p>I want to calculate how many documents are in a collection, not the length of the document. I have tried it with some code but what appears is the length of the character from my document name.</p>
  
  <p><a href="https://i.stack.imgur.com/MWSW9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MWSW9.png" alt="enter image description here"></a></p>
  
  <p>this my code :</p>
  
  <pre><code>StreamSubscription&lt;DocumentSnapshot&gt; userpost;
      final DocumentReference documentReference =
          Firestore.instance.document("product/$documentPost");
      userpost = documentReference.snapshots().listen((datasnapshot) {
        if (datasnapshot.exists) {
          for (int i = 0; i &lt; datasnapshot.data.length; i++){
             print(datasnapshot.data.length);
          }
  </code></pre>