我对这种情况有疑问。你能帮助我吗 ?我正在收到此错误消息。
发生异常。
NoSuchMethodError(NoSuchMethodError:方法'addItem'在null上调用。 接收者:null 尝试调用:addItem(“ {\” name \“:\” example \“,\” isCompleted \“:false,\” isArchived \“:false}”))
我在这里使用addItem;
stepperFormEl.addEventListener('show.bs-stepper', function(event) {
form.classList.remove('was-validated')
var nextStep = event.detail.indexStep
var currentStep = nextStep
if (currentStep > 0) {
currentStep--
}
var stepperPan = stepperPanList[currentStep]
if ((stepperPan.getAttribute('id') === 'test-form-1' && (!$('#inputUserImage').get(0).files.length)) ||
(stepperPan.getAttribute('id') === 'test-form-1' && !anAsyncFunction())) {
event.preventDefault();
form.classList.add('was-validated')
}
})
stepperFormEl.addEventListener('show.bs-stepper', async function(event) {
form.classList.remove('was-validated')
var nextStep = event.detail.indexStep
var currentStep = nextStep
if (currentStep > 0) {
currentStep--
}
var stepperPan = stepperPanList[currentStep]
if ((stepperPan.getAttribute('id') === 'test-form-1' && (!$('#inputUserImage').get(0).files.length)) ||
(stepperPan.getAttribute('id') === 'test-form-1' && !await anAsyncFunction())) {
event.preventDefault();
form.classList.add('was-validated')
}
})
我在这里定义addItem;
floatingActionButton: FloatingActionButton(
backgroundColor: Color(0xff655c56),
onPressed: () async {
String itemName = await showDialog(
context: context,
builder: (BuildContext context) => ItemDialog());
if (itemName.isNotEmpty) {
var item =
Item(name: itemName, isCompleted: false, isArchived: false);
_itemService.addItem(item.toJson());
setState(() {});
}
},
帮助PPP! 赶紧更新btw
答案 0 :(得分:0)
似乎您尝试在addItem
上调用未分配任何内容的_itemService
方法。但是,为获得更清晰的答案,请分享与此问题相关的所有代码。