Being a library hunter
When I was new to Flutter, state management meant picking a library. Provider, Bloc, Riverpod, GetX? I compared star counts and tried them all. The result: whichever I chose, the real problem was never the library.
The real question: where does state live?
Today I start projects with three questions:
- Who owns this data? (A screen, a service, the disk?)
- Who is allowed to change it? One place, or scattered?
- Who needs to hear about the change? One screen today, maybe three tomorrow?
Once the answers are clear, the library almost picks itself. In my decision-engine project the answer was single: all decision state lives in one class, and screens only listen.
class DecisionController extends ChangeNotifier {
Decision? _current;
Decision? get current => _current;
Future<void> submit(Input input) async {
_current = await _engine.evaluate(input);
notifyListeners();
}
}
The structure I can hold in my head
My current rule: state lives as high and as few as possible. Screen-local transient state (a text field, a tab selection) stays on the screen; anything about business logic gathers in the controller. Once that line was drawn, debugging got much faster.
When do you reach for the heavy stuff?
Event-based structures like Bloc shine in genuinely complex flows: multi-step forms, undoable operations. But for most personal projects they are overkill. With a real product and a team, that discipline organizes both the code and the conversation.
The best state management is as much state as you can carry.