【发布时间】:2021-09-06 08:16:48
【问题描述】:
我在 Container 中有 TextFormField,我想在 Container 底部对齐 错误消息 ,但 错误消息 与 TextFormField 有点距离。 错误消息应该会出现在Container中。
如何确定 TextFormField 的高度?
Form(
key: _formkey1,
child:
Column(children: [
Stack(
clipBehavior: Clip.none,
children:[ Container(
width: 990.w,
height: 203.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0.w),
border: Border.all(color: Colors.black12),
),
child: Padding(
padding: EdgeInsets.fromLTRB(46.w, 38.w, 0, 35.w),
child:
Text(
'Current Password',
style: FONT_CONST.MEDIUM
.copyWith(fontSize: 34.w,
color: COLOR_CONST.color_9e9e9e),
),),),
Positioned(
left: 46.w,
top: 105.w,
child:
Container(
width: 881.w,
height: 187.w,
child: TextFormField(
obscureText: true,
validator: (value) {
if (value!.isEmpty) {
return "empty";
}
if (value!=_myInfoProvider.my.password){
return "Please enter your current password";
}
else {
return null;
}
},
style: FONT_CONST.MEDIUM.copyWith(
fontSize: 46.w),
decoration: InputDecoration.collapsed(
hintText: 'Enter Current Password',
hintStyle: FONT_CONST.MEDIUM
.copyWith(fontSize: 46.w,
color: COLOR_CONST.color_c8cacb)),
controller: _textEditingController1,
),
),)
]),
我使用 Stack 小部件是因为 Container 中的 Form 小部件无法返回 错误消息 容器。
【问题讨论】:
-
您的意思是希望错误消息显示在字段底部?
-
尝试为您的问题添加屏幕截图以更详细!
-
谢谢我加了图片!!我想像这样对齐错误消息,但它在容器中对齐。所以我尝试从文本字段中取出 erorMessage 空间。最后将代码编辑为
-
return "\n" "请输入您的当前密码";
-
成功了!!!!感谢您的帮助?????????
标签: android flutter dart textformfield