You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TextField height changes if the errorText shows #15400
Put this in a dialog, and as you type in the text field, the dialog changes height.
newForm(
autovalidate:true,
child:newListBody(
children:<Widget>[
newTextFormField(
decoration:constInputDecoration(
labelText:'User name',
),
validator: (String name) {
if (name.length <2)
return'User names must be alphabetic and at least three characters long.';
},
),
),
],
),
),
Here are some screenshots showing my understanding of the problem:
When the input has an error message, it is considered to be taller than without it, so the parent widget increases its height to accommodate it. That can definitely be pretty jarring for the developer in cases like this dialog or maybe even with a column of text fields.
The referenced PR just adds an explanation of these workarounds to the documentation. I think this is better than changing any behavior. We want to avoid breaking changes. Also, I can see a situation where users want the existing behavior so that they can tightly space their inputs.
Reacted by Masahiro Furudate, ikbal84, Raheleh Shahpasand, Vincent Stollenwerk, becky26, Shyam Parmar, Refik ÖNAL, Muhammed Ballan, Nikolai Pachkov, Jean-benoit Gautier and 5 more
Reacted by Refik ÖNAL
Reacted by AyushmanChatterjee, Shyam Parmar, Refik ÖNAL and Thái Thiên Vũ
Thank you so much! This was driving me insane as I am using two textformfields side by side in a row and the validation errorText kept breaking up the alignment of the form fields. Using an empty helperText was a simple solution to the problem.
The referenced PR just adds an explanation of these workarounds to the documentation. I think this is better than changing any behavior. We want to avoid breaking changes. Also, I can see a situation where users want the existing behavior so that they can tightly space their inputs.
@jacobokoenig I don't think I see the TextFormField becoming smaller in your example. I'm on the master channel. I changed your code by adding a color to the Container so that I could see how tall it is, and I also added autovalidate to your TextFormField so that the error message shows immediately.
Neither the border of the TextFormField or the Container in the background change size after the error appears.
I also encountered the same problem, the workaround that I made was make the fontsize of your errorText and helperText the same so that they will take the space.
@ooanishoo It will probably help if we don't want to show the field validation message.
But if we want to show error message then #15400 (comment) really helpful .
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
alidawud commentedon Oct 8, 2018
this might help you
https://stackoverflow.com/questions/50523006/flutter-increase-height-of-textformfield
SinaSeirafi commentedon Oct 28, 2018
Put the TextFormField inside a Container, and give it a certain height.
That should prevent vertical moving.
babenkovladimir commentedon Feb 8, 2019
I used SizedBox. I set a specific height, which was enough for the height not to jump.
justinmc commentedon Mar 21, 2019
Here are some screenshots showing my understanding of the problem:
When the input has an error message, it is considered to be taller than without it, so the parent widget increases its height to accommodate it. That can definitely be pretty jarring for the developer in cases like this dialog or maybe even with a column of text fields.
I'm going over some solutions and I'll post back.
justinmc commentedon Mar 22, 2019
The two workarounds for this problem are:
helperTextof a single space.The referenced PR just adds an explanation of these workarounds to the documentation. I think this is better than changing any behavior. We want to avoid breaking changes. Also, I can see a situation where users want the existing behavior so that they can tightly space their inputs.
AyushmanChatterjee commentedon Jul 16, 2019
Thank you so much! This was driving me insane as I am using two textformfields side by side in a row and the validation errorText kept breaking up the alignment of the form fields. Using an empty helperText was a simple solution to the problem.
ksankumar commentedon Oct 6, 2019
With
helperTextmakes awesome solutionjacobokoenig commentedon Nov 16, 2019
This is still an issue for me, even with a sizedbox or container, and a helper text! Can't prevent the text field from becoming smaller!
justinmc commentedon Nov 18, 2019
@jacobokoenig I don't think I see the TextFormField becoming smaller in your example. I'm on the master channel. I changed your code by adding a
colorto the Container so that I could see how tall it is, and I also addedautovalidateto your TextFormField so that the error message shows immediately.Neither the border of the TextFormField or the Container in the background change size after the error appears.
camsethsum commentedon Feb 26, 2020
I also encountered the same problem, the workaround that I made was make the fontsize of your errorText and helperText the same so that they will take the space.
psygo commentedon Mar 15, 2020
Taken from this SO answer and the new issue #52634:
There's another alternative to adding extra, permanent padding to cover the
errorText— which would probably mess up many designer's original project.You could create a modified version of the source's
TextFormField.To achieve just that, you can:
TextFormField.TextFormFieldjust so you avoid naming conflicts with the original.TextFormFieldfor, say,TextFormFieldWithErrorTextOption.TextFormField's constructor (below this line), say,errorTextPresent:TextField:TextFormFieldsimilarly to how you use anyTextFormField:ooanishoo commentedon Mar 26, 2020
https://stackoverflow.com/a/60208333/5392889
try this answer. Worked really well for me
TheAlphamerc commentedon Apr 2, 2020
@ooanishoo It will probably help if we don't want to show the field validation message.
But if we want to show error message then #15400 (comment) really helpful .
lock commentedon Apr 19, 2020
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.