← Flutter & Dart learning pathFlutter & Dart · Module 4 of 10
Stateless and Stateful widgets
Manage changing UI with setState.
📖 Key ideas
- StatelessWidget never changes after build.
- StatefulWidget has a State object that can change.
- Call setState(() { count++; }) to rebuild.
- initState runs once; dispose cleans up controllers.
- 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