How to reduce padding between label text and bottom line in TextformField in Flutter?

1,127

Solution 1

With InputDecorationTheme you can style TextformField like you want. Also the padding.

Check this out: https://api.flutter.dev/flutter/material/InputDecorationTheme-class.html

MaterialApp(
        theme: ThemeData(
          inputDecorationTheme: InputDecorationTheme(
            border: OutlineInputBorder(),
            contentPadding: EdgeInsets.symmetric(
              vertical: 22,
              horizontal: 26,
            ),
            labelStyle: TextStyle(
              fontSize: 35,
              decorationColor: Colors.red,
            ),
        ),
)

Solution 2

You should use contentPadding parameter inside TextField's decoration.For example:

    TextField(
        decoration:InputDecoration(
          hintText:"LABEL",
          contentPadding: EdgeInsets.only(top:0.0,bottom:0.0)
        ),
       ),

You can set content Padding as you like to achieve desired results.

Share:
1,127
Abhishek Kumar
Author by

Abhishek Kumar

Updated on December 26, 2022

Comments

  • Abhishek Kumar
    Abhishek Kumar over 1 year

    This is what I have:

    enter image description here

    This is what I want:

    enter image description here

    I want to remove the space between label text and bottom line, how to do that?

    enter image description here

    • Scott Godfrey
      Scott Godfrey over 3 years
      Both images are the same.