title: Flutter firestore - Check if document ID already exists
body: <p>I want to add data into the firestore database if the document ID doesn't already exists.
  What I've tried so far:</p>
  
  <pre><code>// varuId == the ID that is set to the document when created
  
  
  var firestore = Firestore.instance;
  
  if (firestore.collection("posts").document().documentID == varuId) {
                        return AlertDialog(
                          content: Text("Object already exist"),
                          actions: &lt;Widget&gt;[
                            FlatButton(
                              child: Text("OK"),
                              onPressed: () {}
                            )
                          ],
                        );
                      } else {
                        Navigator.of(context).pop();
                        //Adds data to the function creating the document
                        crudObj.addData({ 
                          'Vara': this.vara,
                          'Utgångsdatum': this.bastFore,
                        }, this.varuId).catchError((e) {
                          print(e);
                        });
                      }
  </code></pre>
  
  <p>The goal is to check all the documents ID in the database and see in any matches with the "varuId" variable. If it matches, the document won't be created. If it doesn't match, It should create a new document</p>