From the course: Flutter Essential Training: Build for Multiple Platforms

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

When to use stateless or stateful?

When to use stateless or stateful?

- [Instructor] Whenever you are writing your own app, you will commonly author new widgets that will subclass either a stateless widget or a stateful widget. And you might wonder which one should you go with? Now you understand that a stateless widget cannot be mutated or modified. The configuration that you provide while initializing that widget remains the same and it can never be rebuilt by itself. For example, text and icon widgets are examples of stateless widget. Check the documentation, and you will notice that they subclass stateless widget class. And now you just learned that stateful widgets are a kind of a dynamic widget meaning that the state can change during runtime probably because of some user interaction or typing into a form, or maybe moving a slider, et cetera. A checkbox or radio or slider or text field are examples of stateful widgets. So when you're building your own widget if you know that the widget…

Contents