← Flutter & Dart learning path
Flutter & Dart · Module 4 of 10

Stateless and Stateful widgets

Manage changing UI with setState.

📖 Key ideas

  1. StatelessWidget never changes after build.
  2. StatefulWidget has a State object that can change.
  3. Call setState(() { count++; }) to rebuild.
  4. initState runs once; dispose cleans up controllers.
  5. build() should be fast and free of side effects.
💡 Real-life example: A stateless widget is a printed poster; a stateful widget is a scoreboard that updates.
StatelessWidgetWidget without changing state
StatefulWidgetWidget with mutable state
setStateMarks state changed and rebuilds
disposeCleanup lifecycle method