Flutter · One codebase, native feel

How do you choose a state management approach?

Mediumstate managementarchitecturerebuildsUpdated Oct 2026
Quiz this track

Short answer

Classify state first: ephemeral widget state, shared screen state, and app-wide or server state. Choose the lightest tool that matches the scope, testability and team familiarity rather than defaulting to one framework.

State management is mostly about ownership and rebuild scope. Local UI state can stay in State. Shared state needs a single source of truth with clear lifecycle. Server state has caching, retries and invalidation concerns that differ from form state. Mixing those concerns in one global object is a common source of bugs.

  • Ephemeral state: animation, focus, expansion and text input
  • Screen or feature state: filters, selection and pagination
  • App state: session, theme, locale and feature flags
  • Server state: cached responses, request status and invalidation
  • Derived state should be computed, not stored twice
dart
class CartModel extends ChangeNotifier {
  final List<String> _items = [];

  List<String> get items => List.unmodifiable(_items);

  void add(String item) {
    _items.add(item);
    notifyListeners();
  }
}

class CartScope extends InheritedNotifier<CartModel> {
  const CartScope({
    super.key,
    required CartModel model,
    required Widget child,
  }) : super(notifier: model, child: child);
}

CartModel? readCart(BuildContext context) {
  return context.dependOnInheritedWidgetOfExactType<CartScope>()?.notifier;
}

Selection criteria

I weigh how much boilerplate the team tolerates, whether the state must survive navigation, how easy it is to test without widgets, and how granular rebuilds need to be. Provider is approachable for simple dependency injection. Riverpod improves composition and testability. Bloc gives explicit events and transitions that suit larger teams and audit-heavy flows.

A state management library does not fix poor ownership. If two screens both own the same data, syncing them will stay fragile regardless of the package.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How do you decide whether state is ephemeral or shared?
  2. 2Where does server cache state belong?
  3. 3How do you prevent unnecessary rebuilds when state changes?
  4. 4When would you avoid a state management package entirely?

Say it in the interview

I start by classifying the state. Anything local to one widget, like focus or animation, stays in State. Screen state gets a scoped notifier, and session or server state gets a clear owner with a repository. Then I pick the lightest tool that keeps rebuilds narrow and is easy to test rather than adopting a package just because it is popular.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Flutter mock interview and get scored feedback on depth, clarity and confidence.