如何让 Flutter TextField 接受多行?

How to make Flutter TextField accept multiline?

如何让 Flutter TextField 接受多行?以下代码不起作用:

body: Padding(
    child: Column(
        children: [
            Text('BIO'),
            Expanded(
                child: TextField(
                    autofocus: false,
                    controller: _text,
                    // 
                    keyboardType: TextInputType.multiline,
                    maxLength: null,
                ),
            ),
        ],
        crossAxisAlignment: CrossAxisAlignment.start,
    ),
    padding: const EdgeInsets.all(8),
),

(稍后,我会去掉蓝色下划线,它只是为了表明它是1-liner)。

我在 channel master,v1.2.3-pre.66。

给出 属性 maxLines: nullTextField 小部件

TextField(
  autofocus: false,
  controller: _text,
  keyboardType: TextInputType.multiline,
  maxLength: null,
  maxLines: null,
),
TextField(
  keyboardType: TextInputType.multiline,
  maxLength: null,
  maxLines: null,
)

您只需将 maxLines 设置为 null

只需将 maxLines 设置为 null:

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

如果maxLines属性为null,则不限制行数,启用换行。

你也可以通过添加

来设置最小行数
minLines: 2    //Number of lines(int), you can replace with your number as per your need