What is Widget in Flutter?

Shivam Sharma
2 min readFeb 4, 2020

When I start learning Flutter the first things is to know about Widgets.

What is Widgets?

Widgets is nothing in flutter, it is just a view to render in UI part. In flutter each and everything is working on Widgets. Like when we are creating view in Android app using Java and Kotlin we need xml file for render view in Android studio.

When we are creating view in XML file in Android Studio there is some tags we are using in file like LinearLayout, ImageView, TextView, EditText etc.

In Flutter we have Widgets to render UI in like Row, Column, Center, Text, Container etc.

Row Widget is using for create Horizontal view

Column Widget is used for create Vertical view

Center Widget is used for set Widget in Center of the screen work same as name.

Text widget is used for set text.

Container Widget is used to create rectangular visual element for decoration of widget, give padding and margin.

Like in above code Center and Text is Widget I am using.

As above image we are using three Widgets in app screen :-Image, Text and RaisedButton(Button Widget).

There is some pre-defined Widgets in flutter, but you can create your own Widget in flutter.

For creating your own Widget for that you need to know about StatelessWidget and StatefulWidget. In flutter every where you will see these Widget you extend in class that you create in flutter while developing the app.

StatelessWidget is non-mutable state that mean doesn’t need to track that widget for update like RaisedButton. For more info Click here

StatefulWidget is mutable state that mean we need to track that widget and update it on time interval. In this case we need to call setState() method to update the UI in view. For more info Click here

I hope this article helps to understand what is Widget in flutter.

--

--