title: Get Firestore document key with Flutter
body: <p>I've got the following code from <a href="https://pub.dartlang.org/packages/cloud_firestore#-readme-tab-" rel="nofollow noreferrer">https://pub.dartlang.org/packages/cloud_firestore#-readme-tab-</a>, but I'm not sure how to get each document's key. What I want to do is tap on each term to view or got to an edit page.</p>
  
  <p>Firestore data model:</p>
  
  <pre><code>-content
  --sPuJxAJu0dBMZLBTakd4
  ---term
  ---body content
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>class _TermsState extends State&lt;Terms&gt; {
    @override
    Widget build(BuildContext context) {
      return StreamBuilder&lt;QuerySnapshot&gt;(
        stream: Firestore.instance.collection('content').snapshots(),
        builder: (BuildContext context, AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) {
          if (snapshot.hasError) return Text('Error: ${snapshot.error}');
  
          switch (snapshot.connectionState) {
            case ConnectionState.waiting:
              return Text('Loading...');
            default:
              return ListView(
                children:
                    snapshot.data.documents.map((DocumentSnapshot document) {
                  print(document['term']);
                  return ListTile(
                    title: Text(document['term']),
                  );
                }).toList(),
              );
          }
        },
      );
    }
  }
  </code></pre>