diff --git a/lib/android/config/cast_helper.dart b/lib/android/config/cast_helper.dart index 9f510f0..5220954 100644 --- a/lib/android/config/cast_helper.dart +++ b/lib/android/config/cast_helper.dart @@ -8,8 +8,11 @@ List castDynamicToListFood(List dynamicList) { return foodList; } -Map> castDynamicMap(Map dynamicMap){ +Map> castDynamicMap(dynamic dynamicMap){ Map> foodMap = {}; + if(dynamicMap == null){ + return foodMap; + } for(dynamic key in dynamicMap.keys){ foodMap.putIfAbsent(key as String , () => castDynamicToListFood(dynamicMap[key])); } diff --git a/lib/android/config/statistics.dart b/lib/android/config/statistics.dart index f44d71c..00d11aa 100644 --- a/lib/android/config/statistics.dart +++ b/lib/android/config/statistics.dart @@ -89,9 +89,7 @@ class StatisticsService { void addValuesToList(Box box, String key, List newValues){ List existingList = castDynamicToListFood(box.get(key)); for(int i = 0; i < newValues.length;i++){ - if(!existingList.contains(newValues[i])){ existingList.add(newValues[i]); - } } box.put(key, existingList); } @@ -153,7 +151,7 @@ class StatisticsService { if(matchingTimestamp != null){ newTimestamp = matchingTimestamp; } - Map>? valueMap = castDynamicMap(box.get(newTimestamp)); + Map> valueMap = castDynamicMap(box.get(newTimestamp)); List values = []; if(valueMap.containsKey(mealType)){ values = valueMap[mealType]!;