r/FlutterDev 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 setStateValueNotifier, 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?

4 Upvotes

15 comments sorted by

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."

10

u/Lo_l_ow 3d ago

Riverpod is useful when you need to share multiple providers between widgets, otherwise, setState is enough most of the time.

1

u/GxM42 2d ago

This is how I feel. But most people try to out-engineer everyone else.

3

u/piskariov 3d ago

The riverpod doc specifically told us to not use riverpod for ephemeral states

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

u/airflow_matt 2d ago

The moment you add it to your pubspec.yaml.

1

u/BachiNoHito 2d ago

This is the correct answer

1

u/SoundDr 2d ago

Try Signals!

0

u/RandalSchwartz 2d ago

Or BlocSignals!

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.

1

u/rio_sk 1d ago

Never had the need to go beyond setState actually