doawoo
2 months ago
As a newer user of Flutter I found Riverpod to be extremely heavy and have a lot more mental overhead than using stateless widgets with Hooks.
Any particular reason you personally prefer Riverpod?
dinko7
2 months ago
Hi, author of the article here.
Any state management approach requires you to adapt your way of thinking, whether that be BLoC, Riverpod, Redux or anything you want to use.
Rivepod gained popularity because it's really simple to pick up: create a Notifier, create a Provider for it, and observe, while some other approaches require additional boilerplate, setup, and understanding.
Your approach would work if you are only observing that state from a single widget, which might not always be the case. Additionally, assuming useState is using setState under the hood means it will rebuild the whole widget on change, while with Riverpod, you have the flexibility to wrap any part of a complex widget into a Consumer or listen to only part of the exposed state on the Notifier with .select().
To put it simply: - Notifiers are used for app state - Hooks are used for ephemeral state (local widget state)
Hope this clears it bit for you.
doawoo
2 months ago
Great summary, it does indeed! Thanks for taking the time to reply
XorNot
2 months ago
This was my experience as well. I have however been very happy with get_it <https://pub.dev/packages/get_it> and watch_it <https://pub.dev/packages/watch_it> though, which just totally clicked for me in terms of how it works with the state store (database).
dinko7
2 months ago
That's the beauty of diversity. You can use whatever resonates with you best and still make it work on the app side.
vin047
2 months ago
Riverpod does a lot more than just state management - it also handles dependency injection and reactive caching.
Here’s a great guide on using Riverpod: https://codewithandrea.com/articles/flutter-state-management...
dinko7
2 months ago
Yes it does, and I specifically outlined that in my other article: https://dinkomarinac.dev/riverpod-simplified-lessons-learned...
His question was directed towards the state management, hence the answer only covered that.
wiradikusuma
2 months ago
Check MobX, that's what I ended up using.