title: How do I get documentid of a firestore document in flutter?
body: <p>I have tried the following but it returns a random string which is not present in the firestore.</p>
  <p>I did manage to get documentid of parent collection using a Query Snapshot</p>
  <pre><code>DocumentReference doc_ref=Firestore.instance.collection(&quot;board&quot;).document(doc_id).collection(&quot;Dates&quot;).document();
  
                      var doc_id2=doc_ref.documentID;
  </code></pre>
  <p>More Code: I am getting an error in trying to access the document id. I have tried to use await but its giving an error.</p>
  <pre><code> Widget build(BuildContext context) {
          return Scaffold(
            appBar: new AppBar(
              title: new Text(
                &quot;National Security Agency&quot;,
                style: TextStyle(
                    color: Colors.black,
                    fontWeight: FontWeight.normal,
                    fontSize: 24.0),
              ),
              backgroundColor: Colors.redAccent,
              centerTitle: true,
              actions: &lt;Widget&gt;[
                new DropdownButton&lt;String&gt;(
                  items: &lt;String&gt;['Sign Out'].map((String value) {
                    return new DropdownMenuItem&lt;String&gt;(
                      value: value,
                      child: new Text(value),
                    );
                  }).toList(),
                  onChanged: (_) =&gt; logout(),
                )
              ],
            ),
            floatingActionButton: FloatingActionButton(
              onPressed: () {
      
              },
              child: Icon(Icons.search),
            ),
      
            body: StreamBuilder (
                stream: cloudfirestoredb,
      
      
                    builder: (BuildContext context, AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) {
                      if (!snapshot.hasData) return new Text('Loading...');
      
                      return new ListView(
                        children: snapshot.data.documents.map((document) {
      
      
                          var doc_id=document.documentID;
                          var now= new DateTime.now();
                          var formatter=new DateFormat('MM/dd/yyyy');
                          String formatdate = formatter.format(now);
                          var date_to_be_added=[formatdate];
      
                          DocumentReference doc_ref=Firestore.instance.collection(&quot;board&quot;).document(doc_id).collection(&quot;Dates&quot;).document();
      
                         var doc_id5= await get_data(doc_ref);
      
      
                          print(doc_id);
                          
      
      
                          Firestore.instance.collection(&quot;board&quot;).document(doc_id).collection(&quot;Dates&quot;).document(doc_id5).updateData({&quot;Date&quot;:FieldValue.arrayUnion(date_to_be_added)});
                          return cardtemplate(document['Name'], document['Nationality'], doc_id);
      
                          }).toList(),
                      );
                    },
             ),
                );
        }
  </code></pre>