Home > Back-end >  Fixed space between two TextFormField on Flutter
Fixed space between two TextFormField on Flutter

Time:12-25

I'm trying to create an app for my work with login and signup form.

The page is ok, but there is a litte problem: on each TextFormField there is a validator for check the field, but when appears the error message below the field, the other fields goes down.

The question is: how can I fix the textfields?

This is a gif demostration: https://ibb.co/VwNn2f0

I try to use padding or other method finded here or on google, but I didn't find a solution.

CodePudding user response:

you could wrap your TextField with a SizedBox and set a height for it :

SizedBox(
  height: 80,
  child: TextFormField(
    validator: myValidator,
  ),
),

or you can also set a style for the error text, with a 0 height :

TextField(
  decoration: InputDecoration(
    errorStyle: TextStyle(height: 0),
  ),
);
  • Related