简体   繁体   English

颤动文本框

[英]Flutter textformfield

How can I have a new line property in the textfield widget?如何在文本字段小部件中拥有新行属性? SO that the text entered when reaches a certain point, it shifts to a new line.因此,当到达某个点时输入的文本,它会转移到一个新行。 Can anyone help me fix this?谁能帮我解决这个问题?

Code :代码 :

body: Center(
      child: Container(
        height: 500,
        decoration: BoxDecoration(
            border: Border.all(
              color: Colors.black,
              width: 2,
            ),
            borderRadius: BorderRadius.circular(10)),
        child: Padding(
          padding: const EdgeInsets.only(left: 16.0),
          child: TextFormField(
            decoration: InputDecoration(
                hintText: 'UserName',
                hintStyle:
                    TextStyle(fontWeight: FontWeight.w400, fontSize: 24.0)),
          ),
        ),
      ),
    )

Output:输出:

在此处输入图片说明

From the Official Docs, The maxLines property can be set to null to remove the restriction on the number of lines.从官方文档中可以将 maxLines 属性设置为 null 以取消对行数的限制。 By default, it is one, meaning this is a single-line text field.默认情况下,它是 1,这意味着这是一个单行文本字段。 maxLines must not be zero. maxLines 不能为零。

You just have to add maxLines: null你只需要添加maxLines: null

body: Center(
      child: Container(
        height: 500,
        decoration: BoxDecoration(
            border: Border.all(
              color: Colors.black,
              width: 2,
            ),
            borderRadius: BorderRadius.circular(10)),
        child: Padding(
          padding: const EdgeInsets.only(left: 16.0),
          child: TextFormField(
            maxLines: null,
            decoration: InputDecoration(
                hintText: 'UserName',
                hintStyle:
                    TextStyle(fontWeight: FontWeight.w400, fontSize: 24.0)),
          ),
        ),
      ),
    )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM