skip to Main Content

Stateless
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.Stateful

Android Studio Hedgehog | 2023.1.1 Patch 2
Flutter Doctor

3

Answers


  1. 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.).

    Login or Signup to reply.
  2. 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.

    Plugins setting screenshot

    Now you’ll have the option to convert to StatelessWidget:

    Option screenshot

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search