I used TextFormFied for a text field in flutter application. I want to remove the left padding from flutter validator error message only. I tried contentPadding
, but it also removed input text padding. But I want to remove only error message padding.
How Can I remove this padding only? Can someone help me ?
2
Answers
The below code will create a
TextFormField
.As you can see the
contentPadding
is responsible for the padding oflabelText
anderrorText
. If you change thecontentPadding
toEdgeInsets.symmetric(horizontal: 0.0, vertical: 16.0,)
then thaterrorText
will come at your desired position.Another approach can be to wrap the
TextFormFields
into aColumn
and add aText
Widget at the bottom.Remove the
errorText
from theInputDecoration
.Here you need to manage the show and hide operation of the
Text
by your own logic.There is another way to achieve this UI – You have to take one
Text
widget which will represent your error message. And you have to pass null forTextFormField
validation. Please check below code.Then you have to add padding and space widgets as per your requirement.
Result :