如何解决失败请求的禁用按钮
我使用 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 举报,一经查实,本站将立刻删除。