Warm tip: This article is reproduced from serverfault.com, please click

An error occurs when creating TextEditingController object

发布于 2020-11-28 01:08:52

I have a question An error occurs when creating an object as shown below.

ex)

  final TextEditingController = TextEditingController();

error message is this:

Only static members can be accessed in initializers.

I am curious about the cause of this error and how to fix it

thank you for let me know ~!

error message capture

Questioner
hyun k
Viewed
0
kovalyovi 2020-11-28 10:27:39

Your error here is that you forgot to name your variable. You defined that it is final of type TextEditingController but didn't name the variable. In your case, the fix would be (just a suggestion on the variable name: _controller)

final TextEditingController _controller = TextEditingController();