Lecture 07
Widgets and It's Types and Examples in Flutter, types of widgets in Flutter
Widgets are the basic building blocks of any Flutter app. They are used to define the UI of the app and can range from simple text and images to complex animations and layouts.
There are two types of widgets in Flutter: StatelessWidgets and StatefulWidgets.
StatelessWidget:
StatelessWidgets are widgets that don't have any mutable state. They are immutable and only depend on their constructor arguments and the current configuration. Once they are built, they can't be changed.
Examples of StatelessWidget:
Text: displays a piece of text on the screen.
Image: displays an image on the screen.
Icon: displays an icon on the screen.
RaisedButton: displays a raised button on the screen.
StatefulWidget:
StatefulWidgets are widgets that have mutable state. They can change their appearance and behavior over time based on the state. They are created by extending the StatefulWidget class and implementing the createState() method to return a State object.
Examples of StatefulWidget:
TextField: displays a text input field on the screen.
Checkbox: displays a checkbox on the screen.
Slider: displays a slider on the screen.
Switch: displays a switch on the screen.
Here are some examples of both StatelessWidgets and StatefulWidgets in Flutter:
StatelessWidget example: