在 inputTextForm 字段和底部边框之间颤动 space
flutter space between inputTextForm field and bottom border
除 elements/user 输入和底栏之间的 space 外,一切正常。我尝试了不同的方法来摆脱 space:内容填充、框约束、前缀图标约束等。None 有效。最终我限制了这个小部件的高度,但随后我的错误消息被放置在用户输入的顶部,我收到了这条消息 Another exception was thrown: BoxConstraints has a negative minimum height.
这是代码:
Widget _emailField(FormBloc formBloc) {
return StreamBuilder(
stream: formBloc.email,
builder: (context, AsyncSnapshot<String> snapshot) {
return TextFormField(
autofocus: false,
keyboardType: TextInputType.emailAddress,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if (value == null) {
return "Email cannot be empty";
} else {
if (value.isEmpty) {
return "Email cannot be empty";
}
}
},
onChanged: formBloc.changeEmail,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
prefixIcon: const Icon(
Icons.email,
size: 15,
),
contentPadding: const EdgeInsets.all(0),
labelText: "Email",
labelStyle: const TextStyle(fontSize: 14),
errorText:
snapshot.error != null ? snapshot.error as String : null,
),
);
}
);
}
我需要让一切都像以前一样工作,除了这次我需要在底部边框和输入元素之间没有 space,我该怎么做?
首先在InputDecoration()
里面,你可以给你的prefix icon
zero
padding
。
然后将 prefixIconConstraints
设置为 BoxConstraints(maxHeight:0)
还不够你可以给 contentPadding: EdgeInsets.only(bottom:-5),
.
负值
InputDecoration(
prefixIcon: Padding(
padding: EdgeInsets.only(right:10),
child:const Icon(
Icons.email,
size: 15,
),
),
prefixIconConstraints: BoxConstraints(maxHeight:0),
contentPadding: EdgeInsets.only(bottom:-5),
labelText: "Email",
labelStyle: const TextStyle(fontSize: 14),
errorText:"error",
)
除 elements/user 输入和底栏之间的 space 外,一切正常。我尝试了不同的方法来摆脱 space:内容填充、框约束、前缀图标约束等。None 有效。最终我限制了这个小部件的高度,但随后我的错误消息被放置在用户输入的顶部,我收到了这条消息 Another exception was thrown: BoxConstraints has a negative minimum height.
这是代码:
Widget _emailField(FormBloc formBloc) {
return StreamBuilder(
stream: formBloc.email,
builder: (context, AsyncSnapshot<String> snapshot) {
return TextFormField(
autofocus: false,
keyboardType: TextInputType.emailAddress,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) {
if (value == null) {
return "Email cannot be empty";
} else {
if (value.isEmpty) {
return "Email cannot be empty";
}
}
},
onChanged: formBloc.changeEmail,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
prefixIcon: const Icon(
Icons.email,
size: 15,
),
contentPadding: const EdgeInsets.all(0),
labelText: "Email",
labelStyle: const TextStyle(fontSize: 14),
errorText:
snapshot.error != null ? snapshot.error as String : null,
),
);
}
);
}
我需要让一切都像以前一样工作,除了这次我需要在底部边框和输入元素之间没有 space,我该怎么做?
首先在InputDecoration()
里面,你可以给你的prefix icon
zero
padding
。
然后将 prefixIconConstraints
设置为 BoxConstraints(maxHeight:0)
还不够你可以给 contentPadding: EdgeInsets.only(bottom:-5),
.
InputDecoration(
prefixIcon: Padding(
padding: EdgeInsets.only(right:10),
child:const Icon(
Icons.email,
size: 15,
),
),
prefixIconConstraints: BoxConstraints(maxHeight:0),
contentPadding: EdgeInsets.only(bottom:-5),
labelText: "Email",
labelStyle: const TextStyle(fontSize: 14),
errorText:"error",
)