3 ms·
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 r
by doawoo 1y 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 1y agoHi, 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 1y agoGreat summary, it does indeed! Thanks for taking the time to reply
- vin047 1y agoRiverpod 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-riverpod/ https://codewithandrea.com/articles/flutter-state-management...
- dinko7 1y agoYes it does, and I specifically outlined that in my other article: https://dinkomarinac.dev/riverpod-simplified-lessons-learned-from-4-years-of-development https://dinkomarinac.dev/riverpod-simplified-lessons-learned... His question was directed towards the state management, hence the answer only covered that.
- XorNot 1y agoThis was my experience as well. I have however been very happy with get_it <https://pub.dev/packages/get_it https://pub.dev/packages/get_it> and watch_it <https://pub.dev/packages/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 1y agoThat's the beauty of diversity. You can use whatever resonates with you best and still make it work on the app side.
- wiradikusuma 1y agoCheck MobX, that's what I ended up using.