title: How to return a list from Firestore database as a result of a function in Kotlin?
body: <p>I'm building an app for a friend and I use Firestore. What I want is to display a list of favorite places but for some reason, the list is always empty.</p>
  
  <p><a href="https://i.stack.imgur.com/g2UcI.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/g2UcI.jpg" alt="enter image description here"></a></p>
  
  <p>I cannot get the data from Firestore. This is my code:</p>
  
  <pre><code>fun getListOfPlaces() : List&lt;String&gt; {
      val places = ArrayList&lt;String&gt;()
      placesRef.get().addOnCompleteListener { task -&gt;
          if (task.isSuccessful) {
              for (document in task.result) {
                  val name = document.data["name"].toString()
                  places.add(name)
              }
          }
      }
      return list;
  }
  </code></pre>
  
  <p>If I try to print, let's say the size of the list in <code>onCreate</code> function, the size is always 0.</p>
  
  <pre><code>Log.d("TAG", getListOfPlaces().size().toString()); // Is 0 !!!
  </code></pre>
  
  <p>I can confirm Firebase is successfully installed. 
  What am I missing?</p>