Without padding I get this result:
With something like this
Padding(padding: EdgeInsets.all(20.0), child: TextField())
I get the following result:
It might be a bit hard to see, but you only have to look at the red badge across the edge to realise what I mean.
I would like to only move the text with my padding, but in reality the whole TextField
has the padding applied, i.e. that the underline moves with the padding, but I would like to have the underline still go across the whole view, that only the text inside the TextField
is affected by the padding.
You can set the inner padding of a TextField by using the contentPadding property of the InputDecoration class.
We will use, Padding() and Container() widget to wrap Text() widget and apply padding and margin. Furthermore, you will learn about EdgeInsets method.
As of flutter 1.17. 5 (and still the same in 2. X) 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 has not an inputDecorationTheme attribute.
To apply the padding to the content of the TextField
. You can apply the
contentPadding property of ItemDecoration at decoration property of TextField.
Like this:
TextField( textAlign: TextAlign.left, decoration: InputDecoration( hintText: 'Enter Something', contentPadding: EdgeInsets.all(20.0), ), )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With