【发布时间】:2021-06-05 00:13:05
【问题描述】:
为什么这个方法调用会在这个错误中崩溃?我只想在切换开关时在我的数据库中添加一些数据。
在处理手势时引发以下 NoSuchMethodError: 在 null 上调用了方法“addSystemCategories”。接收方:空 尝试调用:addSystemCategories()
void toggleCategoriesSupport () {
CategoriesProvider categoriesProvider;
categoriesProvider.addSystemCategories();
_categoriesSupport = !_categoriesSupport;
_saveToPreferences();
notifyListeners();
}
这是我调用的方法:
void addSystemCategories() {
final categoryAll = ProductCategory(createdTime: DateTime.now(), id: '0', title: 'Alle', type: 'category');
final categoryNothing = ProductCategory(createdTime: DateTime.now(), id: '1', title: 'Keine', type: 'category');
addCategory(categoryAll);
addCategory(categoryNothing);
}
【问题讨论】:
标签: flutter google-cloud-firestore