I have to pass the same type of data several times, as I have a list of widgets, but I can’t find a way to make this data flow into the provider, as data is generated in another route. To make it more clear, I made some diagrams:
In the CreationScreen3 I have a loaded list of widgets, disposed in a carousel slider, each one of these sliders have a button that leads to a new screen, this screen is where the user will select the data. The available data to pick depends on the previous steps taken by the user. A button confirm the data selected and =>
Provider.of<SelectedDataController>(context, listen: false)
.fillDataMap(confirmedDataMap);
Once the user finish the data selection, the app pop the data selection screen and goes to the CreationScreen3, but the info displayed on the Carousel Option will be changed, based on the data selected previously. Now comes the trouble.
I first tryed to Wrap the CarouselSlider widget with the ChangeNotifierProvider, so I thought that each instance of the carousel slider will have a DataController, and every time this data controller is changed, the widgets would accordingly adjusted. But a get an Exception
*Could not find the correct Provider above this Widget.
This happens because you used a BuildContext
that does not include the provider
of your choice. There are a few common scenarios: […]
*
So I searched in this website for this error and I got the answer in this post:
/questions/57124258/could-not-find-the-correct-provider-above-this-widget
Then I passed the ChangeNotifierProvider to the MaterialApp, that is the only common-parent to both screens.
But I get a Obvious Error, I now only have one instance of the SelectedDataController, so once I select the data, this changes all the widgets.
How can I solve this?