Why does this method call crashes in this error? I just want to add some data in my database when the switch is toggled.
The following NoSuchMethodError was thrown while handling a gesture: The method 'addSystemCategories' was called on null. Receiver: null Tried calling: addSystemCategories()
void toggleCategoriesSupport () {
CategoriesProvider categoriesProvider;
categoriesProvider.addSystemCategories();
_categoriesSupport = !_categoriesSupport;
_saveToPreferences();
notifyListeners();
}
This is the method I call:
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);
}