1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter | FireStore Error: RangeError (index): Index out of range: index should be...

Discussão em 'Mobile' iniciado por Stack, Setembro 27, 2024 às 22:32.

  1. Stack

    Stack Membro Participativo

    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.

    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 = await allData['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

    Continue reading...

Compartilhe esta Página