我正在尝试使我的TextFormField
更大。我试过了这段代码,它确实使它变大了,但是如果我键入(在这里:qwerty),它将从中间开始。是否可以从左上角开始?
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
width: screenWidth / 1.1,
height: screenHeight / 5.5,
child: Form(
key: _form2Key,
autovalidate: true,
child: TextFormField(
validator: (val) {
if (val.trim().length > 200) {
return "Beschrijving te lang";
} else {
return null;
}
},
onSaved: (val) => beschrijving = val,
minLines: null,
maxLines: null,
expands: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
filled: true,
fillColor: Colors.white,
labelText: "",
labelStyle: TextStyle(fontSize: 15.0),
hintText: " ",
),
),
),
),
)
答案 0 :(得分:1)
在我的情况下,这就是我解决的方法。
您可以省略keyboardType: TextInputType.multiline,
,以便允许一个人移至下一行。(输入)
TextFormField(
keyboardType: TextInputType.multiline,
controller: _description,
maxLines: 10,
decoration: InputDecoration(
hintMaxLines: 10,
hintText: "description",
labelText: "Description",
hintStyle: hintText),
),
答案 1 :(得分:1)
您可以尝试一下。
Padding(
padding: EdgeInsets.all(8.0),
child: Container(
width: 400,
height: 120,
child: Form(
autovalidate: true,
child: TextFormField(
autofocus: true,
validator: (val) {
if (val.trim().length > 200)
return "Beschrijving te lang";
else
return null;
},
maxLines: 100,
decoration: InputDecoration(
border: OutlineInputBorder(),
filled: true,
fillColor: Colors.white,
labelText: "",
labelStyle: TextStyle(fontSize: 15.0),
hintText: "Enter a message",
),
),
),
),
)
输出: