如何在Flutter中启用TextField多行文本的hintText?

8

由于[InputDecorator]默认将[maxLines]设置为1,因此我无法找到任何方法在hintText有时有点长的情况下启用多行。

2个回答

13

只需在InputDecoration选项中设置hintMaxLines: 2或您需要的行数即可。

TextField(
  decoration: InputDecoration(
    hintMaxLines: 2
  )
);

1
感谢,多行文本框的工作非常出色:TextField( decoration: new InputDecoration( border: InputBorder.none, hintMaxLines: 3, hintText: '我的非常非常大的提示文本'), keyboardType: TextInputType.multiline, maxLines: null, ) - Hermandroid

-1
在Flutter中,TextField有hintText属性。
 new TextFormField(
          controller: inputBoxController,
          decoration: InputDecoration(
            labelText: inputBoxName,
            hintText: inputBoxName,
          ),
          validator: (val) => val.isEmpty ? msg : null,
          onSaved: (val) => val,
        ),

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接