Choosing: comparison and decision
In a state-management question the interviewer is looking for a decision framework, not package trivia. Start by classifying the state:
- Ephemeral (local) state — belongs to one widget: form text, an expanded panel, an animation. Here `setState` is the right choice and no package is needed
- App state (shared) — spans screens: authentication, the cart, settings, caches. Only this needs a package
Flutter's own documentation opens with exactly this distinction, and moving everything into a package is not what it recommends.
| Criterion | setState | Provider | Riverpod | BLoC |
|---|---|---|---|---|
| Learning cost | None | Low | Moderate | High |
| Boilerplate | None | Little | Little | A lot |
| Testability | Weak | Good | Very good | Very good |
| Compile-time safety | — | Weak | Strong | Moderate |
| Fits | One widget | Small to mid app | Mid to large | Large, team-built |
Interview tip. Do not answer "which state management do you use?" with one word. A strong structure: (1) explain the local/shared split first; (2) say what the current project uses and why it was chosen; (3) acknowledge the alternatives' strengths, which shows you are not dogmatic. The worst answer is "X is the best"; the best is "it depends on context, and in ours X was chosen for these reasons".
📚 Sources and documentation
- Introduction to state managementofficialdocs.flutter.dev
The ephemeral vs app state split is where the official guide starts.
- List of state management approachesofficialdocs.flutter.dev
- App architecture guideofficialdocs.flutter.dev