Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

360
Views
aleteo | Error de FireStore: RangeError (índice): índice fuera de rango: el índice debe ser inferior a 1: 1

Estoy tratando de obtener la lista de documentos de una colección pero tengo el error de fuera de rango. Puede ver la función que devuelve la lista y la salida después.

 Future<List> getPreAppliedUserList() async { try { List? userList = [""]; QuerySnapshot querySnapshot = await _db!.collection(_preAppliedUserCollection).get(); List allData = querySnapshot.docs.map((doc) => doc.data()).toList(); print(allData.length); /// 2 for (int i = 0; i <= allData.length; i++) { userList[i] = await allData[i]['customerNumber']; } return userList; } on FirebaseException { print("getPreAppliedUserList error"); var x; ///todo return x; } }

Error:

 Error: RangeError (index): Index out of range: index should be less than 1: 1
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Las matrices tienen un índice de 0 y allData.length tiene una longitud de 2. Por lo tanto, debe usar:

 for (int i = 0; i < allData.length; i++) { userList[i] = await allData[i]['customerNumber']; }

lo que significa eliminar el <= y reemplazarlo con < ya que no tiene un elemento con el índice 2

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!