gpt4 book ai didi

flutter - 如何改变textformfield中文本的位置?

转载 作者:行者123 更新时间:2023-12-05 04:25:40 29 4
gpt4 key购买 nike

这是我想要的设计: enter image description here

这是我目前的设计: enter image description here

我刚开始使用 flutter。我想就如何根据我想要的设计在 textformfield 中的什么位置制作文本征求意见。我尝试在 textformfield 样式中使用 contentPadding: E​​dgeInsets.symmetric(vertical: 40) 和高度,但仍然无法解决我的问题。请从堆栈溢出中获取建议。

这是我的代码:

Container(
width: double.infinity,
margin: EdgeInsets.fromLTRB(10, 0, 10, 10),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
border: Border.all(
color: Colors.transparent,
width: 1.0,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 30,
child: Text(
'Important patient note',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16),
),
),
SizedBox(
width: 950,
child: TextFormField(
textAlign: TextAlign.start,
style: const TextStyle(color: Colors.black),
controller: importantNotes,
onSaved: (String? value) {
importantNotes.text = value!;
},
decoration: const InputDecoration(
contentPadding: EdgeInsets.all(70.0),
border: OutlineInputBorder(),
hintText: 'Important patient note',
hintStyle: TextStyle(
color: Colors.black, fontSize: 16,),
),
),
)
],
))

最佳答案

只需删除 contentPadding: E​​dgeInsets.all(70.0),

SizedBox(
width: 950,
child: TextFormField(
textAlign: TextAlign.start,
maxLines : 5, // add this
style: const TextStyle(color: Colors.black),
controller: importantNotes,
onSaved: (String? value) {
importantNotes.text = value!;
},
decoration: const InputDecoration(
contentPadding: EdgeInsets.all(70.0), // remove or set it to 0
border: OutlineInputBorder(),
hintText: 'Important patient note',
hintStyle: TextStyle(
color: Colors.black, fontSize: 16,),
),
)),

关于flutter - 如何改变textformfield中文本的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73189774/

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