Ephemeral state vs app state
The official Flutter documentation splits state into two groups.
Ephemeral state (UI state, local state) is state you can neatly contain in a single widget. The official examples: the current page of a PageView, the progress of an animation, the selected tab of a BottomNavigationBar. A StatefulWidget with setState is enough for it.
App state (shared state) is state shared across many parts of the app that you want to keep between sessions. The official examples: user preferences, login info, notifications, the shopping cart, the read/unread state of articles.
| Question | Ephemeral | App state |
|---|---|---|
| Who reads it? | One widget and its subtree | Screens far apart in the tree |
| What happens when the widget is disposed? | It is lost — and that is fine | It must survive |
| Typical tool | `setState`, `ValueNotifier` | Provider / Riverpod / BLoC |
| How it is tested | Through a widget test | A separate unit test, independent of the UI |
The official docs say plainly that there is no universal rule: as an app grows you sometimes have to move ephemeral state into app state. The practical principle the docs cite: do whatever is less awkward. In an interview this answer lands far better than "I always use BLoC".
📚 Sources and documentation
- Ephemeral state vs app stateofficialdocs.flutter.dev
Every definition and example in this topic comes from here.
- Introduction to state managementofficialdocs.flutter.dev
- Simple app state managementofficialdocs.flutter.dev