hyun k
hyun k

Reputation: 191

An error occurs when creating TextEditingController object

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

Upvotes: 1

Views: 32

Answers (1)

kovalyovi
kovalyovi

Reputation: 1039

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();

Upvotes: 2

Related Questions