使 TextField 换行,而不是溢出
Make TextField wrap to a new line, not overflow
我正在使用包裹在 Container
中的简单 TextField
。
当用户键入一个长字符串时,我希望它自动换行。
它目前流出屏幕,在一条线上。我该如何解决这个问题?
您必须将 maxLines
属性 设置为 null
。它默认为 1。
无限行数
new TextField(..., maxLines: null)
或行数有限
new TextField(..., maxLines: 3)
这样当内容超过输入字段的高度时开始滚动
https://docs.flutter.io/flutter/material/TextField/maxLines.html
我正在使用包裹在 Container
中的简单 TextField
。
当用户键入一个长字符串时,我希望它自动换行。
它目前流出屏幕,在一条线上。我该如何解决这个问题?
您必须将 maxLines
属性 设置为 null
。它默认为 1。
无限行数
new TextField(..., maxLines: null)
或行数有限
new TextField(..., maxLines: 3)
这样当内容超过输入字段的高度时开始滚动
https://docs.flutter.io/flutter/material/TextField/maxLines.html