[英]Separate contentPadding for Hint and Error text in TextFormField flutter
Flutter中有什么方法可以分別控制TextFormField中錯誤文本和提示文本的填充? 如果不是,我們如何在 TextFormField 下方制作自定義和單獨的錯誤文本小部件。
試試這個如果對你有幫助
class CustomTextFormFiled extends StatefulWidget {
const CustomTextFormFiled({Key key}) : super(key: key);
@override
_CustomTextFormFiledState createState() => _CustomTextFormFiledState();
}
class _CustomTextFormFiledState extends State<CustomTextFormFiled> {
bool isError = false;
@override
Widget build(BuildContext context) {
return Column(
children: [
TextFormField(
onSaved: (value){
if(value.isEmpty){
isError=true;
}
},
),
if(isError)...{
const Padding(
padding: EdgeInsets.all(10),
child: Text("Error Details"),
)
}
],
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.