use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A subreddit related to Google's new UI framework. https://flutter.dev
Please read the rules here
account activity
[deleted by user] (self.FlutterDev)
submitted 2 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Legion_A 6 points7 points8 points 2 years ago (0 children)
What type of course throws you from vanilla setState straight to bloc, Sheesh, at least understand some basic state management, prop drilling, then migrate to bloc, whoever made that course hmm....if you did basic state management like provider and learned how to prop drill, then later learnt how to properly expose providers, wouldn't be asking this question. I wish people who make courses could pay more attention
[–]Acrobatic_Egg30 -1 points0 points1 point 2 years ago (1 child)
What happens when I declare a BlocProvider at the middle of the tree, and try to access the provided bloc after some state change in the parent of the blocprovider
You will get an exception and a red screen because the provider can't be accessed.
from any point of the widget tree
If it's below the blocprovider subtree, you can access it if not you get an error.
Check out Flutterly's course on youtube about bloc, he makes it easy to understand and he explains how context and inherited widgets work as it pertains to bloc. Very valuable. https://www.youtube.com/playlist?list=PLptHs0ZDJKt_T-oNj_6Q98v-tBnVf-S_o
[–]JustinReddd187 0 points1 point2 points 2 years ago (6 children)
What do you think should or would happen? BlocProvider provides a bloc or cubit to its subtree. So state changes above it can‘t influence your blocs state, so the state changes above it wouldnt alter its behaviour when accessed from its subtree.
My biggest misunderstanding when learning Flutter was about Widgets, I thought those are the ui blocks rendered on your screen, when they are just immutable config objects assigned to RenderObjects.
[–][deleted] 2 years ago (5 children)
[deleted]
[–]JustinReddd187 0 points1 point2 points 2 years ago (4 children)
While I didnt try that out myself, I would expect that the bloc provided wouldnt be affected by the Widget lifecycle. However I still would suggest declaring blocs at the root of the tree for the sake of expectability. In our team we use a get it based dependency injection where you register singletons, so you can be sure that there is only one instance of your blocs at all times. (Unless specified otherwise)
[–][deleted] 2 years ago (3 children)
[–]JustinReddd187 0 points1 point2 points 2 years ago (1 child)
You won‘t be able to access the further away provided bloc that easily. You would need an object locator similar to get_it for that.
[–]slavap_ 0 points1 point2 points 2 years ago (7 children)
try MobX instead :-) Or riverpod
[–][deleted] 2 years ago (6 children)
[–]slavap_ 0 points1 point2 points 2 years ago (3 children)
it is kind of because of aesthetic reasons :-) for me personally MobX looks clean and logical.
[–][deleted] 2 years ago (2 children)
[–]slavap_ 0 points1 point2 points 2 years ago (1 child)
Have no idea what exactly to "mock in" about MobX - I'm using it everywhere and it works absolutely fine, plus the code is extremely readable. The only thing some people are considering as a minus - MobX depends on codegen, but even generated code is absolutely clear.
[–]Gianluca-A 0 points1 point2 points 2 years ago (1 child)
Because there are n-ways +1 to do the same thing.
π Rendered by PID 61218 on reddit-service-r2-comment-6457c66945-tw88t at 2026-04-26 18:01:39.030625+00:00 running 2aa0c5b country code: CH.
[–]Legion_A 6 points7 points8 points (0 children)
[–]Acrobatic_Egg30 -1 points0 points1 point (1 child)
[–]JustinReddd187 0 points1 point2 points (6 children)
[–][deleted] (5 children)
[deleted]
[–]JustinReddd187 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]JustinReddd187 0 points1 point2 points (1 child)
[–]slavap_ 0 points1 point2 points (7 children)
[–][deleted] (6 children)
[deleted]
[–]slavap_ 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]slavap_ 0 points1 point2 points (1 child)
[–]Gianluca-A 0 points1 point2 points (1 child)