4

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

Akif
  • 7,098
  • 7
  • 27
  • 53
Abhishek Kumar
  • 191
  • 1
  • 11

3 Answers3

3

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,
            ),
        ),
)
Marcel Dz
  • 2,321
  • 4
  • 14
  • 49
1

Another useful prop in InputDecoration is alignLableWithHint. This will lower the starting position to the same level as the text/hint text.

Normally the label sits higher, even with contentPadding set to 0

    TextField(
       decoration:InputDecoration(
         hintText:"some label",
         alignLabelWithHint: true,
       ),
     ),
Dan James
  • 546
  • 4
  • 9
  • I would give you more upvotes if I could, I've been wrestling with this for a while and this works a treat. – Matt Booth Oct 07 '22 at 12:32
0

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.

Vinay Jain
  • 398
  • 2
  • 6
  • This only adds additional space, it doesn't remove the spacing that's already there. But the OP's request can sort of be achieved by adding top padding to push the text down. – Tim Aug 28 '23 at 05:42