How do I remove content padding from TextField? How do I remove content padding from TextField? flutter flutter

How do I remove content padding from TextField?


Update (April 2021): still work in flutter 2.0.4

As of flutter 1.17.5 (and still the same in 1.2X) to completely remove or manipulate the padding manually, first you must set isDense: true and then you can adjust the contentPadding as you wanted or apply padding on the parent widget instead.

TextField(  inputDecorationTheme: InputDecorationTheme(     isDense: true,// this will remove the default content padding     // now you can customize it here or add padding widget     contentPadding: EdgeInsets.symmetric(horizontal: 0, vertical: 0),     ...  ),)


You can use contentPadding of InputDecoration. Here is sample code

TextField(   maxLines: 8,   decoration: InputDecoration(      contentPadding: EdgeInsets.symmetric(vertical: 5),      labelText: 'Description',      labelStyle: txtHintStyle,   ) )


I was able to easily achieve that by adding prefix constraints to the prefixIcon and wrapping the prefixIcon with padding like this

      TextFormField(         enabled: true,         decoration: InputDecoration(         prefixIconConstraints:BoxConstraints(minWidth: 23, maxHeight: 20),         prefixIcon: Padding(                       padding: const EdgeInsets.only(right: 20),                       child: Icon(                                Icons.email,                                color: clockColor,                               ),                        ),         hintText:"Email Address"         hintStyle:TextStyle(color: hintColor, fontSize: 14),       ),    ),

heres the output,hope this helps

enter image description here