Why would I ever use StatelessWidget over StatefulWidget?
108
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
.
Author by
Yousef Gamal
Updated on December 08, 2022Comments
-
Yousef Gamal over 1 year
I know that
StatefulWidget
allows us to change widgets, whileStatelessWidget
does not.But if
StatefulWidget
can perform everything thatStatelessWidget
can perform + more, why would I ever useStatelessWidget
overStatefulWidget
?
IsStatelessWidget
better in anyways other than that it's easier to implement?