如何减少颤振中文本字段的额外填充

时间:2020-12-23 17:46:57

标签: flutter flutter-layout flutter-web

我有一个具有一些默认填充的文本字段。我想删除顶部和底部填充。我该怎么做?

下面是图片

image

我尝试将 maxLines 属性赋予 Textfield,但没有奏效。

enter image description here

                                   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),
                                       )

1 个答案:

答案 0 :(得分:0)

只需设置isDense:true

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