颤振中的多行文本字段 [英] Multi-line Textfield in flutter

查看:69
本文介绍了颤振中的多行文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来很简单,但是如何在flutter中创建多行可编辑文本字段? TextField仅适用于单行。

It may sound easy but How can we do a multi-line editable textfield in flutter? TextField works only with a single line.

编辑:一些精确度,因为似乎不清楚。
尽管您可以设置多行以虚拟方式包装文本内容,但仍不是多行。这是一条显示为多行的行。
如果您想做这样的事情,那您就不能做。因为您无权访问 ENTER 按钮。而且没有回车按钮就意味着没有多行。

some precisions because seems like it's not clear. While you can set multiline to virtually wrap the text content, it's still not multiline. It's a single line displayed into multiple lines. If you want to do something like this then you can't. Because you don't have access to ENTER button. And no enter button means no multiline.

推荐答案

要使用自动换行,只需设置 maxLines null

To use auto wrap, just set maxLines as null:

TextField(
  keyboardType: TextInputType.multiline,
  maxLines: null,
)

如果 maxLines 属性为 null ,则行数没有限制,并且自动换行已启用。

If the maxLines property is null, there is no limit to the number of lines, and the wrap is enabled.

这篇关于颤振中的多行文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆