Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot remove underside padding from TextField and TextFormField in Flutter

Tags:

flutter

dart

I have this widget:

TextFormField(
  controller: _activityName,
  autocorrect: true,
  textAlign: TextAlign.start,
  decoration: InputDecoration(
      contentPadding = EdgeInsets.zero,



      border: UnderlineInputBorder(

      ),

      hintText: ""),
  maxLines: 1,
  cursorColor: Colors.white,
),

As you can see I explicitly set the padding to be 0, as this answer said: How do I remove content padding from TextField?

But the result I get is this:

enter image description here

As you can see under the Text MyActivity there is a lot of padding, but I can't get rid of it. It looks like a bug, but I'm not sure:

This is the flutter doctor:

Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.295], locale en-US)
    • Flutter version 1.12.13+hotfix.5 %Flutter path%
    • Framework revision 27321ebbad (3 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0
like image 624
fabriziog Avatar asked Dec 28 '19 15:12

fabriziog


1 Answers

From https://stackoverflow.com/a/59295394/4465386 - check it out for a demo too.

This is how to get 0 padding textFields:

TextField(
  decoration: InputDecoration(
    contentPadding: EdgeInsets.all(0),
    isDense: true,
  ),
);
like image 146
Zvi Karp Avatar answered Sep 18 '22 03:09

Zvi Karp