TechnicalMedium Flutter

Which state management approaches have you used in Flutter, and how do you choose one?

Asked for Mobile Developer

Why they ask this: There is no single right answer; interviewers want reasoning, not a favourite library.

Answer

  • setState: local state inside one widget. Simple and perfectly fine for small screens.
  • InheritedWidget / ValueNotifier + ValueListenableBuilder: built into Flutter and lightweight.
  • Provider: wraps InheritedWidget. Good for simple app-wide state, such as the logged-in user or the theme.
  • Riverpod: a compile-safe evolution of Provider that does not depend on BuildContext. Good for async data and testing.
  • Bloc / Cubit: events and states in streams, with a strict separation between UI and logic. Popular in larger teams.
  • GetX: concise, but often criticised for mixing concerns.

How to choose: keep state as local as possible. Pick a shared solution when several screens need the same data. Consider the team's experience, how testable it is, and how much boilerplate you can accept. Be ready to explain one approach in depth with code from a project you built.

Can you explain this in your own words?

Back to question bank