I'm a little bit confused.
I need guidance regarding this.
CodePudding user response:
Stateless:
Stateless are the that don’t change i.e. they are immutable. Its appearance and properties remain unchanged throughout the lifetime of the widget. In simple words, Stateless widgets cannot change their state during the runtime of the app, which means the widgets cannot be redrawn while the app is in action. Examples: Icon, IconButton, and Text are examples of stateless widgets.
Stateful:
Stateful are the ones that change its properties during run-time. They are dynamic i.e., they are mutable and can be drawn multiple times within its lifetime. It can change its appearance in response to events triggered by user interactions or when it receives data. Examples : Checkbox, Radio Button, Slider, InkWell, Form, and TextField are examples of Stateful widgets. To create a Stateful widget, we have to override the createState() method, which returns the state of the widget.
From my point of view it depends on the condition for what we are using it.
CodePudding user response:
Use stateless with provider state management.
- Create small applications
- Use provider
then you will see the use of Stateless and Stateful widget
CodePudding user response:
Its depend upon your needs and uses
Stateless widget is useful when the part of the user interface you are describing does not depend on anything other than the configuration information and the BuildContext whereas a Stateful widget is useful when the part of the user interface you are describing can change dynamically.
most of the cause stateless widget is most suggestible. you can refer this for more:https://www.bing.com/ck/a?!&&p=5ebfed3e0010d4eeJmltdHM9MTY2NzQzMzYwMCZpZ3VpZD0yZTQ0N2FjNy04NWIyLTY5ZDktMzU2My02OGZjODQxZjY4YjMmaW5zaWQ9NTE5OA&ptn=3&hsh=3&fclid=2e447ac7-85b2-69d9-3563-68fc841f68b3&psq=stateless and stateful widget &u=a1aHR0cHM6Ly93d3cuZ2Vla3Nmb3JnZWVrcy5vcmcvZGlmZmVyZW5jZS1iZXR3ZWVuLXN0YXRlbGVzcy1hbmQtc3RhdGVmdWwtd2lkZ2V0LWluLWZsdXR0ZXIv&ntb=1