我有多种形式的申请表格,当我点击“提交”按钮时,出现错误。我尝试仅使用前4种形式,但仍然有效,我错过了什么吗? 谢谢!
颤振:══╡手势引起的异常CA ══════════════════════════════ 扑:处理手势时引发以下NoSuchMethodError: 颤动:方法“验证”在null上被调用。 颤动:接收者:null 颤抖:尝试调用:validate()
final _formKey = GlobalKey<FormState>();
final _formteleKey = GlobalKey<FormState>();
final _formStraatKey = GlobalKey<FormState>();
final _formNumberKey = GlobalKey<FormState>();
final _formSMOKey = GlobalKey<FormState>();
final _formSTUKey = GlobalKey<FormState>();
final _formSWEKey = GlobalKey<FormState>();
final _formSTHKey = GlobalKey<FormState>();
final _formSFRKey = GlobalKey<FormState>();
final _formSSAKey = GlobalKey<FormState>();
final _formSSUKey = GlobalKey<FormState>();
final _formEMOKey = GlobalKey<FormState>();
final _formETUKey = GlobalKey<FormState>();
final _formEWEKey = GlobalKey<FormState>();
final _formETHKey = GlobalKey<FormState>();
final _formEFRKey = GlobalKey<FormState>();
final _formESAKey = GlobalKey<FormState>();
final _formESUKey = GlobalKey<FormState>();
void save() {
final form = _formKey.currentState;
final form2 = _formteleKey.currentState;
final form3 = _formStraatKey.currentState;
final form4 = _formNumberKey.currentState;
final form5 = _formSMOKey.currentState;
final form6 = _formSTUKey.currentState;
final form7 = _formSWEKey.currentState;
final form8 = _formSTHKey.currentState;
final form9 = _formSFRKey.currentState;
final form10 = _formSSAKey.currentState;
final form11 = _formSSUKey.currentState;
final form12 = _formEMOKey.currentState;
final form13 = _formETUKey.currentState;
final form14 = _formEWEKey.currentState;
final form15 = _formETHKey.currentState;
final form16 = _formEFRKey.currentState;
final form17 = _formESAKey.currentState;
final form18 = _formESUKey.currentState;
if (form.validate()) {
form.save();
}
if (form2.validate()) {
form2.save();
}
if (form3.validate()) {
form3.save();
}
if (form4.validate()) {
form4.save();
}
if (form5.validate()) {
form5.save();
}
if (form6.validate()) {
form6.save();
}
if (form7.validate()) {
form7.save();
if (form8.validate()) {
form8.save();
}
if (form9.validate()) {
form9.save();
}
if (form10.validate()) {
form10.save();
}
if (form11.validate()) {
form11.save();
}
if (form12.validate()) {
form12.save();
}
if (form13.validate()) {
form13.save();
}
if (form14.validate()) {
form14.save();
}
if (form15.validate()) {
form15.save();
}
if (form16.validate()) {
form16.save();
}
if (form17.validate()) {
form17.save();
}
if (form18.validate()) {
form18.save();
}
returnCoordinates();
SUBMIT();
}
答案 0 :(得分:0)
您需要检查是否为所有form
变量分配了其中一个为null的值,这就是为什么。它给出了错误
flutter:在处理以下内容时引发了以下NoSuchMethodError: 手势:颤抖:方法“ validate”在null上被调用。扑: 接收方:空抖动:尝试调用:validate()
您可以通过调试代码进行验证。