Search code examples
flutterdartmaterial-design

Remove default Material design paddings


Basically all Material Design Widget have a default minimum padding, as per their documentation. Is there a way to remove this padding ? For example, a TextFormField while have its label very close to its content, but I haven't found a way to do the same for a DropDownButton, which is annoying since it break the pattern in a form having TextFormFields and DropDownButtons in it.

Many thanks.

Edit : This question provides the widget I need, which doesn't seem to be well known : DropdownButtonFormField. It adds components like a label, which answers my immediate need.


Solution

  • Are you looking for this ?

    TextField(
       decoration:InputDecoration(
          contentPadding: const EdgeInsets.all(0.0),
          isDense:true,
        ),
    

    EdgeInsetsGeometry contentPadding : The padding for the input decoration's container. [...]

    bool isDense : Whether the InputDecorator.child is part of a dense form (i.e., uses less vertical space). default is false