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

How to decrease the extra padding of Textfield in flutter

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

下面是图片

我尝试将 maxLines 属性 指定给文本字段,但没有成功。

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

只需设置isDense:true

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