"Class 'CustomProfile' can't define method 'createState' and have field 'StatefulWidget.createState with the same name

Viewed 30

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

2 Answers

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> {
   ...
}
Related