I am creating a Flutter app. i made the design like this.
My TextFormField form field for email and password heights are small. I want it to be the same size of the bu
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
just so you avoid naming conflicts with the original.
TextFormField
for, say, TextFormFieldWithErrorTextOption
.TextFormField
's constructor (below this line), say, errorTextPresent
:
// `true` is the current implicit default, i.e., showing the `errorText`
bool errorTextPresent = true
TextField
:
decoration: effectiveDecoration.copyWith(field.errorText)
decoration: effectiveDecoration.copyWith(
errorText: errorTextPresent ? field.errorText : null)
TextFormField
similarly to how you use any TextFormField
:
TextFormFieldWithErrorTextOption(
errorTextPresent: false, // `false` will disable the `errorText`
...
),