title: Flutter | FireStore Error: RangeError (index): Index out of range: index should be less than 1: 1
body: <p>I am trying to get the list of documents from a collection but having the out-of-range error. You can see the function that returns the list and the output afterward.</p>
  <pre><code>Future&lt;List&gt; getPreAppliedUserList() async {
      try {
        List? userList = [&quot;&quot;];
        QuerySnapshot querySnapshot =
            await _db!.collection(_preAppliedUserCollection).get();
        List allData = querySnapshot.docs.map((doc) =&gt; doc.data()).toList();
        print(allData.length); /// 2
        for (int i = 0; i &lt;= allData.length; i++) {
          userList[i] = await allData[i]['customerNumber'];
        }
        return userList;
      } on FirebaseException {
        print(&quot;getPreAppliedUserList error&quot;);
        var x; ///todo
        return x;
      }
    }
  </code></pre>
  <p>Error:</p>
  <pre><code>Error: RangeError (index): Index out of range: index should be less than 1: 1
  </code></pre>