-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RepositoryProvider.create and BlocProvider.create must work like didChangeDependencies #1936
Comments
Fix with provider: Pretty fix with Stateful widget Web demo for understand expected flow: |
I am currently solving this problem with a widget like this. |
As appealing as it may sound, there are numerous limitations around InheritedWidgets that makes this approach dangerous. This includes:
We can debate whether these scenarios are worse considering. For now, provider takes the easy path and prevents it to avoid potential surprising behaviors. That's another of the reasons why I made Riverpod. It is able to safely implement such pattern. With Riverpod, those edge-cases do not exist. |
@PlugFox can you take a look at PlugFox/bloc_didchangedependencies#1? I believe I was able to achieve the desired behavior. Let me know what you think 👍 |
@felangel PlugFox/bloc_didchangedependencies#1 This is not a solution of the problem) Need to use This may changed overtime from ui (lifting state) or from data layer. |
@felangel If you need any help, feel free to contact me. I don’t have much time and I don’t want to do a pull request without agreeing on plans, as this may go against your views. Thank you for admitting the problem) |
Marking this as won't fix because this behavior is implemented by |
RepositoryProvider.create and BlocProvider.create must work like didChangeDependencies, not initState.
They must depend on their dependencies like InheritedWidget.
This is
flutter way
andreactive data binding
.I use this crutch with bloc library for blocs lifecycle and dependency management:
https://gist.github.com/PlugFox/80fe552257546f0b50c7f625324da5bf
The text was updated successfully, but these errors were encountered: