skip to Main Content

I tried to get data from Firestore and add it to a list in my flutter app. But although I already put list.add inside the loop, it’s still nothing inside the list.

this is the code I’m trying to do

and this is the output I get

I’m trying to add it to a list because I wanna make a dropdown menu in my flutter app.

2

Answers


  1. Don’t know what state management you are using.

    Basically you need setState() when you add it to the list.

    Login or Signup to reply.
  2.  querySnapshot.docs.forEach((documentSnapshot) {
            Map<String, dynamic> data = documentSnapshot.data();
                 print("Name: ${data['nameCategory']}");
    
          });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search