Flutter: Statefull vs Stateless widget
What is the difference between Stateful and Stateless Widget. In Flutter all the UI components are known as widgets. The widget which contains the code for a single screen of the app can be just of two types — Stateful Stateless Stateless Stateless widgets do not require mutable state, i.e., it is immutable . In simple words, Stateless widgets cannot change their state during the runtime of the app, which means the widgets cannot be redrawn while the app is in action. The structure of a Stateless widget looks like this: So, let’s understand what is there in this small code snippet. The name of this Stateless Widget is “ StartScreen ”, inside which we have to override the “ build” method. This build method takes in a “ BuildContext ” as the parameter and returns a widget. That’s why you can see that the return type of the build method is a widget. And this the place where you can design the UI of this screen, which is Stateless. In Stateless widget, The “ build ” method can be c...
Comments
Post a Comment