update the content of selected tile in gridview in flutter

Viewed 46

I have a selectable grid view on my screen, if you click on a cell it takes you to the next page which contains a list of items. For example a list of fruits. When I click on cell[3], I want to change its blank text to the fruit I selected, for example strawberry, and cell [5] to be banana, but when I click on banana, it changes the text of all cells to banana. How to achieve this? enter image description here

 GridView.count(
                      crossAxisCount: 3,
                      children: List.generate(
                          selectItemsNumber(selectedValue), (index) {
                        return Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: GestureDetector(
                            onTap: () {
                              Navigator.pushNamed(context, "/listOfMiners",
                                  arguments: selectedValue2);
                            },
                            child: Container(
                              child: Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: Column(
                                  mainAxisAlignment:
                                      MainAxisAlignment.center,
                                  children: [
                                    SizedBox(
                                      height: 10,
                                    ),
                                    Text(
                                      widget.selectedMiner.toString(),
                                      style: TextStyle(fontSize: 13),
                                    ),
                                    Text(
                                        widget.selectedMinerTemp.toString())
                                  ],
                                ),
                              ),
                              width: 100,
                              height: 100,
                              color: Colors.blue[200],
                            ),
                          ),
                        );
                      }),
                    ),
0 Answers
Related