Addow
Addow

Reputation: 114

Validating form field in flutter

I have been trying to validate form in Flutter, the validation works but it destroys my design as shown here I tried to validate first name field, the first design was like the last name design but it destroyed when showing error message.

The code for my TextFormFields is here:

_showText('First Name'),
Container(
  height: 50.0,
  padding: const EdgeInsets.all(8.0),
  child: TextFormField(
    decoration: InputDecoration(
      //labelText: 'First Name',
      hintText: 'e.g Ali',
      contentPadding: EdgeInsets.only(left: 10.0, top: 10.0),
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(6.0),
      ),
    ),
    validator: (value){
      if(value.isNotEmpty) {
        return null;
      } else return 'First Name is required';
    },
  ),
),

Someone Show me what is wrong with my design?

Upvotes: 0

Views: 262

Answers (1)

Sidak
Sidak

Reputation: 1283

Your height constraint in the Container is causing problems. Just remove that line and it should be fine

Upvotes: 1

Related Questions