问题描述
我使用 Provider 来验证 TextFormField,它的功能是,当字段为 null 时,按钮将被禁用,直到满足条件。当我第一次启动屏幕并向 TextFormField 输入文本时,验证正常工作,但是当我向服务发出请求但失败时,它会显示警报,但按钮保持启用状态。有什么办法可以在请求失败时清除 TextFormField 并再次禁用按钮而不发送空数据?
CustomButton(
text: Constants.sendInstructions,onpressed: (!resetPassword.isValid)
? null
: () async {
final resetok = await resetService
.sendRecoveryMail(passwordCtrl.text.trim());
if (resetok) {
Navigator.pushReplacementNamed(context,'checkMail');
} else {
showAlert(
context,Constants.resetPasswordData,Color(0XFF2A292B),FontAwesomeIcons.exclamationCircle);
passwordCtrl.clear();
}
//Navigator.pushReplacementNamed(context,'checkMail');
},),
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)