颤动中的多行文本字段 [英] Multi-line Textfield in flutter
问题描述
这听起来很简单,但是我们如何在 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屋!