Types of widgets and there Life Cycle
Types of widgets and there Life Cycle:
Mainly two type of widgets in flutter using these widgets we can create stunning app.
The widgets are as follow:
Stateless widgets.
State full widgets.
Stateless widgets:
Stateless widget are the widgets that do not chance there state like text, image,etc.
A State less widgets are use when the value not change.For example, the screen displays an image with a description and will not change.
The Basic Structure of Stateless widget is as follow:
class JournalList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
);
}
}
State Full Widget:
State full widgets is used when Values have to change means it change the State when the certain event is occurred or data receive.The State full widget are dynamic,
Checkbox
, Radio
, Slider
, InkWell
, Form
, and TextField
are examples of stateful widgets. Stateful widgets subclass StatefulWidget.
Before Touch :
After Touch:
The Basic Structure of State Full widget:
class TapBoxA extends StatefulWidget {
@override
_TapBoxAState createState() => _TapBoxAState();
}
class _TapBoxAState extends State<TapBoxA> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}
Understanding Widget Life Cycle :
State less widget:
State less widget are immutable once drawn function of the state less widget is call only once and no
amount of change in any variable values or event can call it again.
To redraw the State less widget ,we need to create a new instance of the widget.
State full widget:
The State full Widget is mutable and it can drawn multiple time in its life time.
Comments
Post a Comment