gpt4 book ai didi

flutter - TextFormField 通过正确对齐增加高度

转载 作者:IT王子 更新时间:2023-10-29 07:10:37 25 4
gpt4 key购买 nike

我正在尝试使我的 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: " ",
),
),
),
),
)

screenshot code in IOS simulator

最佳答案

你可以试试这个。

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",
),
),
),
),
)

输出:

enter image description here

enter image description here

关于flutter - TextFormField 通过正确对齐增加高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57537325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com