flutter firestore show data

Viewed 26

image

hello, i have cards and the name and surname of the person writes in it.when i click the button next to it, i want it to navigate to another page and in big card writes the whole information about that person saved in firebase(name,surname,medicine,illness etc).i did the navigate part, can you help me?

return Dismissible(
                                onDismissed: (_) {
                                  data.docs[index].reference.delete();
                                },
                                key: UniqueKey(),
                                direction: DismissDirection.endToStart,
                                background: Container(
                                  color: Colors.red,
                                  child: Icon(
                                    Icons.delete,
                                    color: Colors.white,
                                  ),
                                  alignment: Alignment.centerRight,
                                ),
                                child: Card(
                                  child: ListTile(
                                    trailing: Wrap(
                                      children: [
                                        IconButton(
                                          icon: Icon(Icons.edit),
                                          onPressed: () {
                                            Navigator.push(
                                                context,
                                                MaterialPageRoute(
                                                    builder: (context) =>
                                                        UpdatePatient()));
                                          },
                                        ),
                                        IconButton(
                                          icon: Icon(Icons.search),
                                          onPressed: () {
                                            Navigator.push(
                                                context,
                                                MaterialPageRoute(
                                                    builder: (context) =>
                                                        ShowPatient()));
                                          },
                                        ),
                                      ],
                                    ),
                                    title:
                                        Text("${data.docs[index]["name"]}"),
                                    subtitle: Text(
                                        "${data.docs[index]["surname"]}"),
                                  ),
1 Answers

You need to pass the Id of the patient you click on to the other page(ShowPatient()) and then accept that id from the ShowPatient() screen and with that Id you will have to filter the list which you have all the patients and then get the patient that you want with the Id that you have, that is the basic logic that you need to implement,

You can refer to this repo for a more practical and clean way to do this.

Related