DEV Community

Cover image for Flutter Widgets Stateless – Stateful Widget Difference

Posted on

Flutter Widgets Stateless – Stateful Widget Difference

We will discuss the concept of widget, which is one of the structures we hear the most in Flutter. At the same time, we will talk about Stateless and Stateful widgets that change shape according to our page structure.

What is widget?

Almost everything in Flutter is widget, and the concept we call widgets are components that are given to us ready-made. Many structures, like each interface element, are considered as widgets. You can review the widget catalog to look at Flutter's widget features and examples. Using these widgets, we can develop our application easily and quickly. It is appropriate, we use widgets within the widget. For this, it is important to understand the widget structure. We should know that each structure is actually a widget and the features of these widgets.

Speaking of nested widgets, we can give an example. While some widgets accept only one widget; some widgets can accept multiple widgets inside. We can think of it this way. In Flutter, there is a widget called Column, which we will cover in detail as page structures in the following lessons, it can take multiple widgets. Because we can think of the Column widget as a list that is aligned one after the other. Thus, we can easily understand that it can actually take more than one element. However, we think of the Container widget as a box, and we can add only one element to it.

Basic widget structures for Flutter

Let's also talk about MaterialApp and Scaffold and AppBar widgets, which are the most used widgets.

The MaterialApp widget is one of the richest widgets. After we create our project in our Main class, we usually give a material app inside the run app method. In order to use other widgets, we especially need the MaterialApp widget for routing. When we build our application, we can consider this widget as its outermost part.

Then Scaffold widget means screen. We create our screen with Scaffold. If we don't create the scaffold, if we add it in, we will see a black screen. After creating a white screen with Scaffold, it is entirely up to us to shape it.

The AppBar widget is a structure that we created at the top of the screen that we created with Scaffold. Here we can write the name of the application, change the color of the area like this top line.

What is a state?

Continue this post on my blog! Flutter Widgets Stateless – Stateful Widget Difference.

Discussion (0)