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
    ),
  ),
 ),
Share:
1,936
Mohamed Ali
Author by

Mohamed Ali

Updated on December 10, 2022

Comments

  • Mohamed Ali
    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 it

    Is 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
    Mehmet over 4 years
    Thanks for the very clean solution @Ovidiu :)
  • Purvik Rana
    Purvik Rana about 4 years
    This answer is kind of a miracle #Kudos