Hello there!
After going trough issues #74 #763 #776 I have to ask a question myself, I have uploaded the minimal (not) working code here: https://github.com/Vash1/flutter_weather_settings
The Problem:
Triggering the Toggle event on a Switch on Page2 works. But after returning to Page1 and again going to Page2, the initialState is fired again, resetting my choice.
My Analysis so far:
Following the advices I mentioned, this issue is gone
BlocProvider.of() called on a context that does not contain a Bloc of type SettingsBloc. No ancestor could be found starting from the context ...
But somehow my code ended up with 2 BlocProviders, leading to multiple instatiations of the SettingsBloc.
Maybe I ended up with 2 Instances of the same bloc in different contexts? Or am not refreshing/listening for changes on my HomePage properly? Because also the "Center Text $state.xyz" on my Page1 always stays unchanged when I return from Page2.
This already took me a good amount of time so now I had to ask, and I'm very grateful for advices and help.
Thanks.
Hi @Vash1 馃憢
Thanks for opening an issue!
I've opened a pull request to address the issue. You were creating multiple instances of the SettingsBloc rather than reusing the existing instance when navigating to the SettingsPage.
Hope that helps 馃憤
Most helpful comment
Hi @Vash1 馃憢
Thanks for opening an issue!
I've opened a pull request to address the issue. You were creating multiple instances of the
SettingsBlocrather than reusing the existing instance when navigating to theSettingsPage.Hope that helps 馃憤