This commit is contained in:
2025-04-27 14:07:29 +03:00
parent 670878c2e7
commit 97313b1857

View File

@@ -17,11 +17,16 @@ class SheetStore extends ChangeNotifier {
}
/// Updates [item] in the store.
void update(String itemID, dynamic value) {
void update(String itemID, dynamic value, {bool addIfAbsent = false}) {
if (!_items.containsKey(itemID)) {
throw Exception('No item with the ID $itemID exist in the SheetStore, Are you sure you added it?');
if (addIfAbsent) {
add(itemID, value);
} else {
throw Exception('No item with the ID $itemID exist in the SheetStore, Are you sure you added it?');
}
} else {
_items[itemID] = value;
}
_items[itemID] = value;
// This call tells the widgets that are listening to this store to rebuild.
notifyListeners();
}