The Flutter TextEditingController
does not clear the text in a TextFormField
that is set to readOnly
because readOnly
means that the text field is not editable by the user, but it can still be modified programmatically.
In other words, setting a TextFormField
to readOnly
does not prevent the TextEditingController
from modifying its text. Therefore, clearing the TextEditingController
's text in a readOnly
field would contradict this behavior.
If you want to clear the text in a readOnly
field, you can use the TextEditingController
to set its text to an empty string. However, you should also change the field's readOnly
property to false
before clearing the text, and revert it back to true
afterward. This ensures consistency between the field's readOnly
property and its current state.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-12-03 11:00:00 +0000
Seen: 11 times
Last updated: Feb 22 '23
How can I prevent the modification of another object's property through reference?
What is the method to make a TextButton inactive when the text field has no text?
Can you explain the meaning of "Linearizability"?
Why is BindingResult.rejectValue unable to locate the value from ValidationMessages.properties?
Is there an equivalent of the CSS property "float:right" in LinearLayout on android?
What is the method for including MSBuild parameters in launchSettings.json?
Is there a potential for a conflict between the name of a class and the name of a property?