Why my createState() is wrong? i dont know how i can resolve that

52 views Asked by At

I have an error on my flutter code, i dont know where is the error, if i put a getter, it dissappier, but... i dont know if that soluction is great. enter image description here Class 'MyHomePage' can't define method 'createState' and have field 'StatefulWidget.createState' with the same name. Try converting the method to a getter, or renaming the method to a name that doesn't conflict.dart(conflicting_method_and_field)

but if i put an getter: enter image description here

thanks you!

How i can resolve that?

1

There are 1 answers

1
Dharini On

replace your line with create state line with

@override
State<MyHomePage> createState() => _MyHomePageState();

For the best practice do not write this manually.

just write stful and press enter it will auto generate stateful class for you & you have to write class name.That's the shortcut of generate basic structure of stateful class