TextFormField多行输入

时间:2020-05-27 18:40:05

标签: flutter dart

我正在做一个联系表,在身体上我需要它更高并且能够放回车键(就像您按回车键一样,它会停止书写。

这是我当前的代码:

TextFormField(
      validator: (value) {
        if (value.isEmpty) {
          return 'Please enter a ${widget.name}';
        }
        return null;
      },
      style: TextStyle(
          color: Colors.white
      ),
      cursorColor: Colors.white,
      decoration: InputDecoration(
        focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(color: kBlue)),
        enabledBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.grey)),
        labelText: 'Enter the ${widget.name}',
        labelStyle: TextStyle(
          color: Colors.grey,
        ),
      ),
    );

1 个答案:

答案 0 :(得分:0)

您可以这样做:

TextFormField(
  keyboardType: TextInputType.multiline,
  minLines: 2,
  maxLines: 3,
)