How to Remove Error Message in TextFormField in Flutter
Try the code bellow. No size adjustment for the error text, only the field border in red.
TextFormField(
decoration: InputDecoration(
errorStyle: TextStyle(height: 0),
),
);
You can return an empty string which will still mark the borders red if not valid
validator: (String value) {
if (value.isEmpty) {
return '';
}
},
UPDATE
What I did to fix that was wrap the TextField with SizedBox and give a fixed height then want expand with error message
SizedBox(
height: SOME_FIXED_HEIGHT_INCLUDING_ERROR_MESSAGE'S_HEIGHT,
child: TextField()
This works perfect for me. Looks pretty clean although you lose, of course, the error info coming from the validation.
TextFormField(
decoration: const InputDecoration(
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
errorStyle: TextStyle(height: 0),
),
validator: (_) => error ? '' : null,
),