"Which state management should I use in Flutter?" is the most common question I get, and the honest answer is: all three of these work. What matters is picking one deliberately and using it consistently. I have shipped production apps with BLoC, Riverpod, Provider and GetX, so here is how I actually decide.
The same feature three ways
The feature: load a list of products, show loading and error states.
BLoC
Events in, states out. Explicit and verbose, which is a feature on big teams.
sealed class ProductsEvent {}
final class ProductsRequested extends ProductsEvent {}
sealed class ProductsState {}
final class ProductsLoading extends ProductsState {}
final class ProductsLoaded extends ProductsState {
ProductsLoaded(this.items);
final List<Product> items;
}
final class ProductsFailure extends ProductsState {
ProductsFailure(this.message);
final String message;
}
class ProductsBloc extends Bloc<ProductsEvent, ProductsState> {
ProductsBloc(this._repo) : super(ProductsLoading()) {
on<ProductsRequested>((event, emit) async {
emit(ProductsLoading());
try {
emit(ProductsLoaded(await _repo.fetch()));
} catch (e) {
emit(ProductsFailure('$e'));
}
});
}
final ProductRepository _repo;
}
Riverpod
Providers are declarative and testable, and async state is built in.
final productsProvider = FutureProvider<List<Product>>((ref) {
return ref.watch(productRepositoryProvider).fetch();
});
// In the widget
final products = ref.watch(productsProvider);
return products.when(
data: (items) => ProductList(items),
loading: () => const CircularProgressIndicator(),
error: (e, _) => ErrorView('$e'),
);
Provider (ChangeNotifier)
The simplest to read. It also leaves the most up to you.
class ProductsNotifier extends ChangeNotifier {
ProductsNotifier(this._repo);
final ProductRepository _repo;
List<Product> items = const [];
bool loading = false;
String? error;
Future<void> load() async {
loading = true;
error = null;
notifyListeners();
try {
items = await _repo.fetch();
} catch (e) {
error = '$e';
}
loading = false;
notifyListeners();
}
}
Notice the Provider version allows an impossible state: loading == true and error != null at once. BLoC's sealed states and Riverpod's AsyncValue make that unrepresentable.
Comparison
| BLoC | Riverpod | Provider | |
|---|---|---|---|
| Boilerplate | High | Low to medium | Low |
| Impossible states | Prevented by sealed states | Prevented by AsyncValue | Easy to create |
| Testing | Excellent (bloc_test) | Excellent (provider overrides) | Good |
| Async handling | Manual | Built in | Manual |
| Onboarding a team | Clear conventions | Needs a learning curve | Easiest |
| Traceability | Event log of every change | Observers available | Limited |
How I choose
- Large app, several developers, strict conventions: BLoC. The event and state types act as documentation, and every change is traceable.
- Small team, lots of async data, fast iteration: Riverpod.
- Small app or a few shared values: Provider is fine. Do not over-engineer.
Whatever you pick, keep it behind your architecture. If your widgets depend on use cases and repositories rather than on Dio, switching later is a presentation-layer change; see Clean Architecture in Flutter.
Mistakes I see repeatedly
- Mixing three state managers in one app because each tutorial used a different one.
- Business logic inside widgets. State management is where logic lives, not
build. - One giant state object for a whole screen. Split state by responsibility.
- Not testing it. The reason to adopt any of these is testability; see how to test Flutter apps.
Key takeaways
- All three are production-ready. Consistency beats the "perfect" choice.
- Model loading, success and error as one type so impossible states cannot exist.
- Choose by team size and conventions, not by trend.
Working on a Flutter team that needs this kind of judgment? Contact me.