When I click on stateless widgets name, is shows a bulb. By clicking on it, I get an option to convert into stateful widget.
But when I want to convert a stateful into a stateless, I can’t find the bulb. I tried Alt+Enter but no luck.
Remove the State class that’s associated with the stateful widget.
Remove any state-related methods such as createState() and the state lifecycle methods (initState(), build(), etc.).
You are probably using an outdated version of the Flutter plugin. In previous versions, it is only possible to convert from StatelessWidget to StatefulWidget. Upgrade your Flutter plugin to the latest version to enable converting from StatefulWidget to StatelessWidget.
You can check/update plugins by going to File > Settings > Plugins.
Now you’ll have the option to convert to StatelessWidget:
3
Answers
Remove the State class that’s associated with the stateful widget.
Remove any state-related methods such as createState() and the state lifecycle methods (initState(), build(), etc.).
You are probably using an outdated version of the Flutter plugin. In previous versions, it is only possible to convert from
StatelessWidget
toStatefulWidget
. Upgrade your Flutter plugin to the latest version to enable converting fromStatefulWidget
toStatelessWidget
.You can check/update plugins by going to
File > Settings > Plugins
.Now you’ll have the option to convert to
StatelessWidget
:In vs code you can convert it by doing the ( ctrl+ . ) and can convert it to
and if your are using the setstate try to magange that