【问题标题】:How to increase the length of a TextField while pressing "Enter" in Flutter?在 Flutter 中按“Enter”时如何增加 TextField 的长度?
【发布时间】:2022-01-11 15:02:37
【问题描述】:

我有一个 maxLength 设置为 150 的文本字段。但是,我希望 textField 的 maxLine 属性在按 Enter 时增加 1。请问我怎样才能做到这一点?

在下面找到我的代码:

child: Padding(
                      padding: const EdgeInsets.all(20.0),
                      child: TextField(
                        maxLines: 5,
                        maxLength: 150,
                        controller: _userAboutController,
                        decoration: InputDecoration(
                          helperText: '(Optional)',
                          labelText: user.about,
                          icon: Image.asset(
                            "Assets/images/country.png",
                            height: 40.0,
                          ),
                          focusedBorder: UnderlineInputBorder(
                            borderSide:
                            BorderSide(color: secondaryColor, width: 2.0),
                          ),
                      ),
                    ),
                  ),

【问题讨论】:

    标签: flutter textfield


    【解决方案1】:
    1. 声明int maxLines = 5

    2. 按下回车后,为maxLines添加增量。

      maxLines ++;

    3. 终于改变了textField

      maxLines: 5maxLines ;

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2019-06-29
      • 2012-03-01
      • 1970-01-01
      • 2020-07-13
      • 2018-06-21
      • 2021-03-21
      • 2016-11-11
      • 1970-01-01
      相关资源
      最近更新 更多