Flutter - can't see validation messages for disabled form fields
1,936
Simply add an InputDecoration
with an errorStyle
to the TextFormField
to use any color you want for the error, which applies for both enabled and disabled fields:
TextFormField(
...
decoration: InputDecoration(
errorStyle: TextStyle(
color: Theme.of(context).errorColor, // or any other color
),
),
),
Author by
Mohamed Ali
Updated on December 10, 2022Comments
-
Mohamed Ali over 1 year
For my
Flutter
App, I'm using many input form fields for data input, and assigning a validation method for each, for all fields the error message appears normally, just below the field, except for one field that takes value from a picker dialog, so that i made it disabled (enabled=false
) to prevent user input on itIs it normal that a disabled field doesn't show validation error messages? if yes, should i do something different to prevent user input on that field other than making it disabled?
-
Mehmet over 4 yearsThanks for the very clean solution @Ovidiu :)
-
Purvik Rana about 4 yearsThis answer is kind of a miracle #Kudos