如何让Flutter TextField接受多线?

问题描述 投票:0回答:2

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

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

(稍后,我将删除蓝色下划线,它只是显示它是一个1班轮)。

我在频道大师,v1.2.3-pre.66。

Multiline problem in Flutter

flutter flutter-layout
2个回答
2
投票
TextField(
  keyboardType: TextInputType.multiline,
  maxLength: null,
  maxLines: null,
)

您所需要的只是将maxLines设置为null


2
投票

将属性maxLines: null提供给TextField小部件

TextField(
  autofocus: false,
  controller: _text,
  keyboardType: TextInputType.multiline,
  maxLength: null,
  maxLines: null,
),
© www.soinside.com 2019 - 2024. All rights reserved.