简体   繁体   English

如何减少flutter中Textfield的额外填充

[英]How to decrease the extra padding of Textfield in flutter

I have a Textfield which is having some default padding.我有一个文本字段,它有一些默认填充。 I want to remove the top and bottom padding.我想删除顶部和底部的填充。 How can I do it?我该怎么做?

Below is the image下面是图片

图片

I tried giving maxLines property to Textfield but it didn't work.我尝试将 maxLines 属性赋予 Textfield,但没有成功。

在此处输入图像描述

                                   TextField(
                                         onChanged:
                                         bloc.changeRole,
                                         decoration: new InputDecoration(
                                             contentPadding:
                                             EdgeInsets.symmetric(
                                                 vertical: 0,
                                                 horizontal: 15.0),
                                             border: new OutlineInputBorder(
                                                 borderSide:
                                                 const BorderSide(
                                                     width: 2.0,
                                                     style:
                                                     BorderStyle
                                                         .solid),
                                                 borderRadius:
                                                 BorderRadius
                                                     .circular(
                                                     50.0)),
                                             focusedBorder:
                                             OutlineInputBorder(
                                               borderSide:
                                               const BorderSide(
                                                   color:
                                                   Colors.grey,
                                                   width: 2.0),
                                               borderRadius:
                                               BorderRadius.circular(
                                                   50.0),
                                             ),
                                             hintText: 'Role',
                                             hintStyle: new TextStyle(
                                                 color: Colors.grey,
                                                 fontWeight:
                                                 FontWeight.bold),
                                             errorText: snapshot.error),
                                       )

Just set isDense:true只需设置isDense:true

TextField(
      decoration: new InputDecoration(
        isDense: true,
        contentPadding: const EdgeInsets.symmetric(vertical: 0, horizontal: 15.0),
      ),
),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM