Search code examples
flutterdartflutter-layout

How to convert a Stateful widget into a Stateless widget in flutter?


I have a stateful widget and I want to convert it into a stateless widget. I know how to convert a Stateless widget into a Stateful widget. Just like a Stateless widget is there any shortcut available to convert a Stateful widget.

I am using an Android Studio. Thanks :)


Solution

  • One Simple Trick

        class Counter extends StatelessWidget {
    //   @override
    //   _CounterState createState() => _CounterState();
    // }
    
    // class _CounterState extends State<Counter> {
      @override
      Widget build(BuildContext context) {
        return Container(
          
        );
      }
    }
    

    Just comment in between and change the statefulwidget to statelesswidget