From 97313b18573378cee18a5156c8a0917f15ed5798 Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Sun, 27 Apr 2025 14:07:29 +0300 Subject: [PATCH] [SYNC] --- lib/src/sheet/src/models/sheet_store.model.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/src/sheet/src/models/sheet_store.model.dart b/lib/src/sheet/src/models/sheet_store.model.dart index a375d2e..5a21bdb 100644 --- a/lib/src/sheet/src/models/sheet_store.model.dart +++ b/lib/src/sheet/src/models/sheet_store.model.dart @@ -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(); }