What is ephemeral (local) state?
Ephemeral state is temporary UI state contained within a single widget.
Learn what state is and why it matters
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
State is any data that can change over time and affects what the UI displays. Whenever state changes, Flutter rebuilds the affected widgets to reflect the new values. Examples of state include:
Flutter state falls into two main categories depending on how widely it is used across your app.
Ephemeral (Local) State is UI state that a single widget manages on its own. No other widget needs to know about it. Examples include:
App State is state that multiple widgets across different screens need to share and react to. Examples include:
1// Ephemeral state - use setState()2class Counter extends StatefulWidget {3@override4_CounterState createState() => _CounterState();5}67class _CounterState extends State<Counter> {8int _count = 0; // Local state910void _increment() {11setState(() {12_count++; // Update state13});14}1516@override17Widget build(BuildContext context) {18return Text('Count: $_count');19}20}
setState() only works for local widget state. For shared state across multiple widgets, you need a state management solution like Provider or Riverpod.
For every state value, define one owner.
When ownership is unclear, duplicate state and inconsistent UI quickly appear.
Learn what state is and why it matters. State is data that changes over time and controls what users see on the screen.
Connect each concept to real app features you can build.
Keep state as close as possible to where it is used, then lift it only when sharing is required.
State management is the difference between predictable apps and hard-to-debug UI behavior.
Ephemeral state is temporary UI state contained within a single widget.
User auth affects many screens, making it app state that needs to be shared.
setState() marks the widget as dirty and triggers a rebuild of the widget subtree.
User login status is app state because it affects multiple screens, not just one widget.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue