본문 바로가기

Flutter-플러터/플러터 공부

TextFormFiled 에서 initalValue 와 Controller

반응형

결론 : intitalvalue 와 contrller는 같이 못쓴다!!!!

 

 

The error message "AssertionError ('package:flutter/src/material/text_form_field.dart': Failed assertion: line 157 pos 15: 'initialValue == null || controller == null': is not true.)" indicates that you are using a TextFormField widget in your Flutter application, and you have provided both initialValue and controller properties to the widget, which is not allowed according to the assertion check in the Flutter framework.

In Flutter, a TextFormField can have either an initialValue or a controller, but not both. The initialValue property is used to set the initial value of the form field when it is first rendered, while the controller property is used to bind the form field to a TextEditingController that allows you to control and manipulate the value of the form field dynamically.

To fix this error, you need to choose either initialValue or controller based on your use case. If you want to set the initial value of the form field, you can use initialValue and remove the controller property. If you want to dynamically control the value of the form field, you can use controller and remove the initialValue property.

Here's an example of how you can fix the error by removing the initialValue property and using only the controller property:

반응형