juniorFlutter

Difference between StatelessWidget and StatefulWidget?

Updated Apr 28, 2026

Short answer

StatelessWidgets are immutable and their UI cannot change dynamically, whereas StatefulWidgets maintain state that can change over time.

Deep explanation

A StatelessWidget is built once and doesn't hold any mutable state. Its build method runs only when its parent re-renders it. A StatefulWidget has an associated State object that persists across builds. Calling setState() within the State object triggers the build method to reflect the updated state.

Real-world example

Use StatelessWidget for static text labels or icons; use StatefulWidget for a checkbox or a like button that changes appearance when tapped.

Common mistakes

  • Using a StatefulWidget when the UI never actually changes, which wastes memory.

Follow-up questions

  • What is the lifecycle of a StatelessWidget?
  • Can a StatelessWidget contain a StatefulWidget?

More Flutter interview questions

View all →