skip to Main Content

App view

I tried to list the data I received from Firebase in the dropdown menu in the dialog. I don’t get any errors in coding, but when clicking the menu it doesn’t open. Where am I doing wrong?

StatefulBuilder(builder:
    (BuildContext context,
        StateSetter setState) {
  return DropdownButton<String>(
    isDense: true,
    hint: new Text("Proje Seçiniz"),
    value: _selected1,
    onChanged: (newValue) {
      setState(() {
        _selected1 = newValue;
      });

      print(_selected1);
    },
    items: data.map((list) {
      return DropdownMenuItem<String>(
        child: Row(
          children: [
            Image(
                image: NetworkImage(list[
                    "personelResim"])),
            Container(
                margin: EdgeInsets.only(
                    left: 10),
                child: Text(
                  list["name"] +
                      " " +
                      list["surname"],
                  style: TextStyle(
                      fontSize: 25),
                )),
          ],
        ),
      );
    }).toList(),
  );
}),

Firebase data retrieval codes

List data = [];


var response;

await _firestore.collection("personeller").get().then((data) {
  response = data.docs[0].data();
  data = jsonDecode(response);
});

2

Answers


  1. Chosen as BEST ANSWER

    I solved my problem with a different usage. I used the question asked here before for the different method.

    Source


  2. I think that you’re changing the data that has come as a response, try to:

    List something = [];
    
    
    var response;
    
    await _firestore.collection("personeller").get().then((data) {
      response = data.docs[0].data();
      something = jsonDecode(response);
    });
    

    Let me know if it works, good luck!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search