How to add character limit or restrict max length of the text field in flutter without using onchange attribute?
How to add character limit or restrict max length of the text field in flutter without using onchange attribute?
You could use the maxLength property of the TextField to limit the length of the text without using onChanged():
TextField(
maxLength:10
decoration: InputDecoration(
counterText: '' //hides the counterText on the bottom of the TextField
),
),
The above will set your TextField's maxLength to 10. Here is the documentation for maxLength