How do you manage state in a Flutter or React Native app as it grows beyond a few screens?
What the interviewer wants to hear
- Separate local UI state from shared app or server state
- Use a state library (Riverpod, Bloc, Redux Toolkit, Zustand) for shared state
- Use a server-state cache (TanStack Query) for API data
- Unidirectional data flow and immutable state
- Keep business logic out of widgets or components so it is testable
Model answer
I first split state into types. Local UI state, like whether a dropdown is open, stays in the widget or component with setState or useState. Shared app state, like the logged-in user or cart, goes in a dedicated layer: in Flutter I usually use Riverpod or Bloc, and in React Native Zustand or Redux Toolkit. Server data is really a cache, so in React Native I use TanStack Query, which handles loading, caching, refetching and invalidation, and in Flutter a repository with a provider that exposes async values. I keep data flowing one way: the UI dispatches events, logic updates immutable state, and the UI rebuilds. Business logic lives outside widgets so it can be unit tested. I also scope providers or selectors carefully so a change only rebuilds the parts of the screen that use it.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Mobile App Developer questions
- How would you add offline support to an app that currently only works online?
- Users say a list in your app stutters while scrolling. How would you find and fix the problem?
- Walk me through how you release a new version of a mobile app to the stores.
- What is dependency injection and how have you used it in a mobile app?
- What security practices do you follow when building a mobile app?
- What testing strategy do you use for a mobile app, and what do you test at each level?
- How would you implement deep links in a mobile app from end to end?
- How do you make a mobile app accessible, and how do you check it?
- How would you set up CI/CD for a mobile app?