diff --git a/lib/features/shopping_list/providers/shopping_list_provider.dart b/lib/features/shopping_list/providers/shopping_list_provider.dart index d100f40..79fef9e 100644 --- a/lib/features/shopping_list/providers/shopping_list_provider.dart +++ b/lib/features/shopping_list/providers/shopping_list_provider.dart @@ -6,6 +6,7 @@ import '../../../core/constants/app_constants.dart'; class ShoppingListProvider extends ChangeNotifier { List _items = []; + int _idSeq = 0; List get items => _items; List get pendingItems => @@ -39,7 +40,7 @@ class ShoppingListProvider extends ChangeNotifier { _items = [ ..._items, ShoppingItem( - id: DateTime.now().millisecondsSinceEpoch.toString(), + id: '${DateTime.now().millisecondsSinceEpoch}_${_idSeq++}', name: t, ), ]; @@ -61,11 +62,10 @@ class ShoppingListProvider extends ChangeNotifier { } final toAdd = []; - var i = 0; for (final entry in counts.entries) { if (existing.contains(entry.key)) continue; toAdd.add(ShoppingItem( - id: '${DateTime.now().millisecondsSinceEpoch}_${i++}', + id: '${DateTime.now().millisecondsSinceEpoch}_${_idSeq++}', name: canonical[entry.key]!, quantity: entry.value, ));