title: The first function is too slow, what can I do?
body: <p>I have a problem. I have two functions, but the first function is too slow, so the second function can't work correctly. I saw that the problem can be solved with async and await, but I don't know how this works. The function submit() is too slow. Can anyone tell me how it works?</p>
  <p>This is my code:</p>
  <pre><code>  submit() {
      FirebaseFirestore.instance
          .collection('seller')
          .where('name', isEqualTo: widget.name)
          .get()
          .then((value) {
        value.docs.forEach((result) {
          print(result.id + ' --------------------');
          documentID = result.id;
          print(documentID);
        });
      });
      print('test--------------------------');
      addData();
    }
  
    addData() {
      Map&lt;String, dynamic&gt; data = {'name': 'Paul'};
      Firestore.instance
          .collection('seller')
          .document(documentID)
          .collection('test')
          .add(data);
    }
  </code></pre>