Home > OS >  "Class 'CustomProfile' can't define method 'createState' and have fiel
"Class 'CustomProfile' can't define method 'createState' and have fiel

Time:09-13

you can see my screen there
 you can see my screen there I didn't have this problem before, but today, I wanted to create another page.dart in addition to my main.dart but it didn't work. So I cancelled everything I had put in and then I found that I had this error in my main.dart. Even when I open another project I have this error when I put the StatefulWidget on VS code or Android Studio please help me

CodePudding user response:

The problem is that you just put a '_' in front of the states name.

This underscore marks the State as private but does not change its name.

Try to name the State something like 'CustomProfileState'.

Example:

class CustomProfile extends StatefulWidget {
   @override
   CustomProfileState createState() => CustomProfileState();
}

class CustomProfileState extends State<CustomProfile> {
   ...
}

CodePudding user response:

Even when I open another project, I've still the same issues enter image description here

  • Related