Home > database >  Adding a New Image and it changes all images at front page - Flutter
Adding a New Image and it changes all images at front page - Flutter

Time:08-17

I am making demo application for experience. So, the problem is that I am adding list as described in images(Screenshots). But when I add another new list with image so, it automatically changes images at front page in the last and new list both. So, can you guys suggest, how we can get new image in list only once and last list stay the same as we added before.

enter image description here

The code is below.

enter image description here

Thanks in advance.

CodePudding user response:

The problem is you are using the list to add images to the list. As the list is callByReference it will change the value inside the list when the value of the listOfImage is changed.

To fix the issue you can change the addition method to map like

allData.add(Model(listOfImage:List.from(list)));

hope it will work for you if not let me know.

  • Related