Search code examples
dartflutterstatefulwidgetstatelesswidget

Why would I ever use StatelessWidget over StatefulWidget?


I know that StatefulWidget allows us to change widgets, while StatelessWidget does not.

But if StatefulWidget can perform everything that StatelessWidget can perform + more, why would I ever use StatelessWidget over StatefulWidget?
Is StatelessWidget better in anyways other than that it's easier to implement?


Solution

  • You'll get a small performance gain using StatelessWidget. It's very negligible but it's there.

    Outside of this, there are some architectural gains. A StatelessWidget is entirely immutable. This is important enough to justify using Stateless over Stateful when there's no need for a State.