【问题标题】:Flutter TextFormField pointer overlapping the textFlutter TextFormField 指针与文本重叠
【发布时间】:2020-03-24 13:02:46
【问题描述】:

当在 Flutter 中使用 TextFormField 并在表单中预填文本时,当我点击它的某个位置以开始编辑文本时,我会在文本上看到一个小雨滴指针:

我希望它出现在表格下方一点。像这样的:

代码如下:

                  Container(
                    height: 40.0,
                    child: TextFormField(
                      style: TextStyle(
                        fontSize: 17,
                      ),
                      controller: serverAddressController,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(
                          borderRadius: new BorderRadius.circular(10.0),
                        ),
                      ),
                      onChanged: (value) {
                        serverAddress = value;
                        changesSaved = false;
                      },
                      textInputAction: TextInputAction.next,
                      onFieldSubmitted: (_) {
                        FocusScope.of(context)
                            .requestFocus(daysBackFocusNode);
                      },
                    ),
                  ),

我该怎么做?

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    您已将容器高度设置为低,但未减少内容填充 只需添加contentPadding 属性

    decoration: InputDecoration(
      contentPadding: EdgeInsets.only(left: 16, right: 16),
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(16.0),
      ),
    ),
    

    【讨论】:

    • 看准了!谢谢!
    猜你喜欢
    • 2022-01-22
    • 1970-01-01
    • 2021-10-05
    • 2021-01-13
    • 2021-10-14
    • 2019-12-25
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多