0

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],
                            ),
                          ),
                        );
                      }),
                    ),
mary
  • 37
  • 7
  • You mean you are in page1 witch has selectable grid, you go to page 2 select a value then bring back that value to page1 and update the clicked cell?, is this what you want to do? – Ridha Rezzag Sep 13 '22 at 14:23
  • Please share your code so we can check it – Code Master Sep 13 '22 at 14:42
  • @RidhaRezzag yes exactly – mary Sep 13 '22 at 17:01
  • @CodeMaster please check it now – mary Sep 14 '22 at 17:49
  • You have to come up with a strategy, what you can do you can move to page 2 select the value and send it back as an argument to page1, or you can save the value in shared preference from page2 then when go back to page1 you can get the value from shared preference page1 see https://stackoverflow.com/a/61987148/6561930 – Ridha Rezzag Sep 14 '22 at 19:35

0 Answers0