Home > Software engineering >  In 'class My Home Page extents', there is an error in 'My Home Page' with a red
In 'class My Home Page extents', there is an error in 'My Home Page' with a red

Time:07-22

enter image description here

I would appreciate it if you could tell me how to correct the error.

CodePudding user response:

StatefulWidget is malformed. The build method must be implemented in State.

class MyHomePage extends StatefulWidget {
  final String title;

  MyHomePage({required this.title});
  
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    ///your Code
  }
}

CodePudding user response:

The structure of your stateful widget looks wrong

class YellowBird extends StatefulWidget {
  const YellowBird({ Key? key }) : super(key: key);

  @override
  State<YellowBird> createState() => _YellowBirdState();
}

class _YellowBirdState extends State<YellowBird> {
  @override
  Widget build(BuildContext context) {
    return Container(color: const Color(0xFFFFE306));
  }
}
  • Related