Stateful and Stateless widgets in Flutter

Mahi!
feedflood
Published in
1 min readAug 18, 2019

The first hard thing in flutter was understanding the widgets. After that, there were stateful and stateless widgets. Here let’s talk about the later headache in simplest terms that I can explain.

State:

This is just a variable. we use them in all the other languages. x=19` is a state. It is just some information about something in your app that may change.

Stateless Widget:

A stateless widget has a state which doesn’t change once it has been initialized. The state is final and stays the same throughout the app.

for example, you can set a string to some variable and use that variable everywhere in the app but can’t change its value.

Stateful Widget:

In stateful widgets, you can change the value(State) of a variable whenever you want to. These can change dynamically based on user interactions with the app or can be triggered when some events occur.

Suppose you add a button and want to change the color or text of the button when the user interacts then you can simply assign a new value to that variable whenever the desired event occurs.

--

--