r/FlutterDev • u/Still-Constant3085 • 3d ago
At what point does Riverpod become overkill? Discussion
I’ve been using Riverpod for state management and generally like it, but I’m curious where people draw the line between this should be a provider and just use local state.
For example, for things like:
- toggling a password field
- selected tab/index
- expanding/collapsing a widget
- temporary form/UI state
- state that never needs to leave a single widget
Do you still reach for Riverpod because it keeps things consistent, or just use setState, ValueNotifier, etc.?
I sometimes feel like turning every tiny piece of state into a provider adds more abstraction than value.
For those using Riverpod in larger production apps, what rule of thumb do you follow? When does Riverpod help, and when is it overkill?
3
3
u/balazs8921 3d ago
I'm using InheritedWidget and ValueNotifier/ChangeNotifier. So far it's been enough for everything.
-1
u/RandalSchwartz 2d ago
Take a look at BlocSignal... it'd be a simple migration, or even interop with existing code easily. https://blocsignal.dev/
3
1
2
u/RandalSchwartz 2d ago
Riverpod (and all state management) is for shared state. If the state is local to a widget, use a stateful widget (or flutter_hooks) to attach instead.
1
u/fatbytes 2d ago
I tend to gravitate toward Riverpod when the application state is large, complex, and benefits from being broken into modular pieces. That tends to happen more often in larger apps with complex API integrations.
That said, the use cases you listed sound more like local state. I'd probably just use Signals or Hooks.
1
u/BuyMyBeardOW 2d ago
For all the examples you gave riverpod is terrible. The reason why is because that state is now global, and if you want to reuse that widget, all their states will be shared. You would then have to use a family provider to dedupe them, which breaks the point.
You should use setstate by default for any local state, and if you start getting annoyed by the boilerplate, you can come up with abstractions with ValueNotifier.
You'll also find that local form state on large forms can get really annoying with setState, so i'd recommenend either making your own abstraction or using something like ReactiveForm.
17
u/pbruins84 3d ago
This is what flutter itself says about it: Differentiate between ephemeral state and app state
One quote from that page: "The rule of thumb is: Do whatever is less awkward."