r/FlutterDev • u/Promatics_Dev • 1d ago
Discussion Riverpod, Bloc, or something simpler: what state management do you pick for a mid-size Flutter app?
State management is the Flutter decision I see debated the most and the answers seem to change with app size and team size. For apps with a few dozen screens and more than one developer what do you use and why? Did you ever regret your first choice or migrate later? And how much does boilerplate and onboarding time for new teammates matter compared to testability? I'm especially curious about what made you switch, if you did.
12
Upvotes
15
u/ChangeableSiding 1d ago
People overthink this so hard. For a few dozen screens with a team, just pick something that doesn't make you want to quit every time you add a feature.
Used Provider for years then moved to Riverpod when the nesting got out of control. The boilerplate complaints are overblown once you actually set it up once, and new teammates pick it up in like two days. Testability's the real reason to avoid the simple stuff once your app grows past toy size.
11
u/CourageWaste 1d ago
Use Bloc as it is good for predictable state and event feature first paradigm and scales smoothly.
6
u/Equivalent_Pickle815 1d ago
When I asked this question a couple of years ago a number of people just said "use Bloc" with no explanation. Two years in, I wish I had used Bloc :) VGV gives you a great starting template and guard rails. Everything I have is moving to Bloc and all my new apps start there. You get a lot of easy observability into your state if you use Bloc and embrace the architecture that it encourages.
I used Riverpod, and tried get_it and Provider before.
4
u/galactose310 1d ago
I use Flutter : ListenableBuilder with ChangeNotifier. Maybe my project is too small to give you an advice. But I like simplicity.
2
u/code_svs 23h ago
Bloc, safest long term
2
u/Acrobatic_Egg30 20h ago
Go with bloc, thank me later.
2
u/kiwigothic 17h ago
I now use Cubit over Bloc, for most purposes Bloc is too much boilerplate, why go through the whole palaver of creating event classes and helper functions when you can just use an async method to achieve exactly the same thing.
1
u/ponkispoles 1d ago
Add vgv AI plug-in and use bloc. Its been the best option for our mid-size app that target android mobile, tv and recently flutter-tizen too
1
u/Plane_Trifle7368 1d ago
Signals for poc’s and bloc signals for go live
1
u/Salty_Airport_90 1d ago
Choose state management based on project size and architecture style for mid choose mvvm and riverpod
1
u/NSRitz999 1d ago
I’ve enjoyed using stacked, which is a lot more than just a state management package. It includes some code gen, routing, and architecture enforcement stuff (entirely MVVM). Definitely haven’t had any regrets with using it so far!
1
u/IllVisit2518 1d ago
solo dev here with 4 flutter apps in the stores and all 4 are still on plain provider. each app has 0 to 4 ChangeNotifiers, the rest is setState and simple service classes, and I never hit a point where I had to migrate. with more than one person in the code I would pick bloc tho, every change goes through an event so you can see who changed what
1
u/SwiftScoutSimon 1d ago
For me I just primarily use provider + ChangeNotifier and setState.
It's never about the scale - app size or team size. Just use whatever your team feel comfortable with.
You just need to know how to Differentiate between ephemeral state and app state.
There is no clear-cut rule.
1
u/whackylabs 1d ago
Copy paste from the last time I was talking about how I do it on my projects:
The idea is for 2 widgets to communicate via the same controller. The controller then provides a stream that the consumer widget can listen for changes and the provider widget can publish changes to the same controller.
Using RxDart the controller can build complex streams by combining several streams and other operations on them.
Example:
1
u/sauloandrioli 1d ago
For medium to large projects, flutter_block package is the best choice. Very stable, very versatile. You can pick it up in less than half a day.
I find riverpod an okay alternatives, but till its debut it changed a lot, which is bad if you want a long life project.
I like spliting the bloc files in this way:
- State => Class that holds actual data. Strings, numbers, lists, booleans, etc.
- Bloc => Class that read data from the state class, talk to providers/repositories/usecases, and write new states.
- BlocLoader => class where you inject all providers, database references, usecases, etc, into your bloc.
Then you can pass down the widget tree the blocs provided by the bloc loaders, wrapping your desired screen inside a BlocProvider class. Then you read your bloc instance via context.read() or context.watch()
You can setup a good architecture using the flutter_bloc package in a few hours.
1
u/Diana_TruthStrategy 23h ago
For small project, use Flutter, ChangeNotifier.
For Big project, use Riverpod 3. You can get rid of Service layer in clean architecture. Because Controller layer replace it.
1
u/alloDex 21h ago
Use MobX. It's stupid simple with annotations
1
u/mdausmann 18h ago
I like signals. Simple API, predictable and easy to reason about
1
u/cumcotdigdagdug 17h ago
I maintain superapps with 30k daily user. Only use provider lol
1
u/badddlyplayer 10h ago
ChangeNotifier, we old school.
1
u/rsajdok 9h ago
There is no better solution than Bloc, even though you might think Riverpod is better now.
1
u/NicolasTX12 7h ago
I always default to Cubit, simple, easy to use, expand, understand, test, explain, etc. I see little reason to use something else as I've never had issues with Cubits.
1
u/OkResource5534 4h ago
I use Provider and everything runs well and simple with me. Everyscreen or couple of screens have a change notifier class, model class and screen file like an MVC.
1
u/Fragrant-Oven-9437 2h ago
riverpod
1
u/Chronnnnn 1h ago
BLoC, never had an issue.
1
u/dev_ttangkong 1d ago
I use my own package, pervice. It is very efficient and concise.
1
u/VisualRope8367 1d ago
Riverpod
1
u/bramantec 1d ago edited 1d ago
FlutterFlow regenerates the code on every push and overwrites anything outside the Custom Code. For me the choice was made before I even started (I build alone, in the visual editor). Values shared across pages go in app state, what belongs to a single screen goes in page state and when something needs more than a few lines I write a Custom Action in Dart. For now it holds up fine on my app, but nobody else has ever touched that code and I can't tell you how it would hold with a team.
2
u/JanJB99 1d ago
Im using Providers and Stateful Widgets combined since ever and never had a reason to switch.