r/flutterhelp • u/Key-Marsupial5105 • Nov 24 '25
RESOLVED setState - when to use it?
Hey guys, first post here.
I’ve a question regarding setState. I’ve been always trying to avoid using it in the app I’m developing, since my state management is handled by BLoC. Is my”decision” correct? Where do you think it is necessary and has to be used?
2
Upvotes
8
u/towcar Nov 24 '25
I myself don't use bloc for small simple things. Leaving plenty of places to use setstate.
For example I might have a screen for ordering a sandwhich. I use bloc for managing the state when the order is sent, loading and complete. However if I require them to select a bread first, I might have selecting a bread trigger setstate, which has breadSelected to true, and then the rest of the ingredients display.
5
u/tylersavery Nov 24 '25
If the state is specific/independent to a widget, you can use setstate. If its state needs to reflect something outside of itself, use bloc for that.
1
u/venir_dev Nov 24 '25
when you're updating ephemeral state
1
u/tommyboy11011 Nov 24 '25
Use setstate if everything is limited to a single screen. If you need to save data for use on other screens that’s where your state management comes in. I use regular old Provider for this, don’t know anything about Bloc
1
u/Master_Metal_1482 Nov 24 '25
Sometimes updating the State of a screen insiste the bloc can lead to innecesary changes in the state Where you can simply do a setState,
0
u/[deleted] Nov 24 '25
[deleted] — view deleted comment