Answers for "Failed assertion:'initialValue == null || controller == null': is not true."

1

Failed assertion:'initialValue == null || controller == null': is not true.

You can't use initialValue and controller at the same time. So, a better way is to use controller because its constructor does provide you initial value that you can set.

Here is an example.

// In class level 
final controller = TextEditingController(text: "Your initial value");

Widget build(BuildContext context) {
  return TextFormField(
    controller: controller, 
    // ...
  );
}

In order to track the value entered by the user you can then use

controller.text
Posted by: Guest on May-21-2021

Code answers related to "Failed assertion:'initialValue == null || controller == null': is not true."

Code answers related to "Dart"

Browse Popular Code Answers by Language