About Stateful and Stateless widget

Stateful vs Stateless widget in flutter

Tony Wilson jesuraj
2 min readAug 3, 2021

In this blog, we going to look at Stateful and Stateless Widgets.

Before into the topic, let's know what is a widget?

What is a widget in flutter?

In flutter, if you take any element it will be called a widget (eg. Text widget, app bar widget, container widget). So using what widget depends on the developer's needs.(Your flutter application itself an widget here)

Widget is to construct UI.

What is Stateless?

  • Simply we can say it as a static one.
  • Can not be altered once they are built
  • Immutable
  • Simple text will be an example of stateless

What is Stateful?

  • Simply we can say it as a Dynamic one.
  • Can be altered once they are built. User can interact with a stateful widget
  • For example: if your screen contains a button if the button pressed background changed or like this interaction happened user and app. this will come under the stateful widget.

Both image shows you the example of stateful and stateless widget, Inside this we will create the widget we need.

Summary

In simple words Stateful = dynamic and stateless = static. This is simple explanation for stateful and stateless widget. If any doubt or wrong in this blog reach me in comments

If any mistake or you need to shout me, comments session in always opened

நன்றி வணக்கம்

--

--