-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextField height changes if the errorText shows #15400
Comments
Put the TextFormField inside a Container, and give it a certain height. |
I used SizedBox. I set a specific height, which was enough for the height not to jump. |
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. |
The two workarounds for this problem are:
SizedBox(
height: 80,
child: TextFormField(
validator: myValidator,
),
),
TextFormField(
decoration: const InputDecoration(
helperText: ' ',
),
validator: myValidator,
), 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. |
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. |
With |
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!
|
@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 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. |
Taken from this SO answer and the new issue #52634: There's another alternative to adding extra, permanent padding to cover the You could create a modified version of the source's To achieve just that, you can:
|
https://stackoverflow.com/a/60208333/5392889 try this answer. Worked really well for me |
@ooanishoo It will probably help if we don't want to show the field validation message. |
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 |
Put this in a dialog, and as you type in the text field, the dialog changes height.
cc @HansMuller
The text was updated successfully, but these errors were encountered: