title: What is the ValueEventListener equivalent in Firestore for FLUTTER app
body: <p><strong>Updated!!</strong></p>
  <p>Let's assume I have collection with name <strong>collection_name</strong> with document id <strong>signed_user_id</strong> . I am trying to listen the child node <strong>signed_user_id</strong> and perform one task only if that document <strong>signed_user_id</strong> changes. <em>It is working but called twice when trying to listen the document changes.</em></p>
  <pre><code>_listenForHtmlContentUpdate() {
  widget.firestore
      .collection('collection_name')
      .document('signed_user_id')
      .snapshots()
      .listen((event) {
    print('object');
    print(event.data);
  });
  </code></pre>
  <p>And in this second case, let's assume I have inner collection and inner document with name <strong>html_doc</strong>. So, I want to listen when <strong>html_doc</strong> document field changes. <em>This function is not working when I use multiple collection and document. I mean when trying to listen the inner <strong>html_doc</strong> document updates/changes.</em> So, how to listen the inner document changes using flutter?</p>
  <pre><code>_listenForHtmlContentUpdate() {
  widget.firestore
      .collection('collection_name')
      .document('signed_user_id')
      .collection('html')
      .document('html_doc')
      .snapshots()
      .listen((event) {
    print('object');
    print(event.data);
  });
  </code></pre>
  <p>}</p>
  <p><strong>Firestore Update calling Twice Case:</strong> Acc to documentation, Local writes in your app will invoke snapshot listeners immediately. This is because of an important feature called &quot;latency compensation.&quot; When you perform a write, your listeners will be notified with the new data before the data is sent to the backend.</p>
  <p>Retrieved documents have a metadata.hasPendingWrites property that indicates whether the document has local changes that haven't been written to the backend yet. You can use this property to determine the source of events received by your snapshot listener. This is the reason behind calling twice.</p>
  <pre><code>_listenForHtmlContentUpdate() {
  print('_listenForHtmlContentUpdate *****');
  widget.firestore
      .collection('resume')
      .document('signed_user_id')
      .snapshots()
      .listen((event) {
    // check and perform the task accordingly.
    var source = event.metadata.hasPendingWrites ? &quot;Local&quot; : &quot;Server&quot;;
    print(source);
  });
  </code></pre>