【问题标题】:How to decrease the extra padding of Textfield in flutter如何减少颤动中Textfield的额外填充
【发布时间】:2021-04-02 08:04:41
【问题描述】:

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

下面是图片

我尝试将 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),
                                       )

【问题讨论】:

    标签: flutter flutter-layout flutter-web


    【解决方案1】:

    只需设置isDense:true

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

    【讨论】:

      猜你喜欢
      • 2022-11-05
      • 2020-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-24
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      相关资源
      最近更新 更多