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

Unlock the full course today

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

Writing your first stateful widget

Writing your first stateful widget

- [Instructor] All this time, we were creating stateless widget to replace the static UI that we have been building till now. Like this chat and put all the chat bubbles, were all stateless widgets. But let's create a stateful widget and show you how it differs. Let's simply just recreate the default counter app. Now, do you remember the shortcut we learned earlier for creating stateless widget? Now for a stateful widget, we have the stful. Usually you get the suggestion once you write stf itself. Now we have to fill in the class name which in this case could be CounterStateful. Let's also import the material class. So now the errors are gone. So now here, you see two glasses being created. One is a subclass of StatefulWidget and another is a subclass of State. This State class contains the widget's mutable state and the widget's build method that you're already familiar with. This is where you define the UI, your…

Contents