diff --git a/lib/android/components/card_component.dart b/lib/android/components/card_component.dart index 9665103..d5405b2 100644 --- a/lib/android/components/card_component.dart +++ b/lib/android/components/card_component.dart @@ -92,17 +92,6 @@ class _CardComponentState extends State { return calories.round(); } - Map> getMapOfDistinctElementsWithCounterAndCalories(List foods){ - Map> resultMap = >{}; - for(int i = 0; i < foods.length;i++){ - if(!resultMap.keys.contains(foods[i].name)){ - resultMap.putIfAbsent(foods[i].name, () => [1,foods[i].calories]); - }else{ - resultMap[foods[i].name]![0] = resultMap[foods[i].name]![0] + 1; - } - } - return resultMap; - } @override Widget build(BuildContext context) { return Card( diff --git a/lib/android/config/format_helper.dart b/lib/android/config/format_helper.dart index 76297ee..098156b 100644 --- a/lib/android/config/format_helper.dart +++ b/lib/android/config/format_helper.dart @@ -1,5 +1,20 @@ +import '../models/food.dart'; + String getFoodListStringByFood(String foodName, int count, int calories){ int maxWidth = 35; String limitedText = foodName.length > maxWidth ? "${foodName.substring(0, maxWidth - 3)} ... $count x $calories kcal" : "$foodName $count x $calories kcal"; return limitedText; } + + +Map> getMapOfDistinctElementsWithCounterAndCalories(List foods){ + Map> resultMap = >{}; + for(int i = 0; i < foods.length;i++){ + if(!resultMap.keys.contains(foods[i].name)){ + resultMap.putIfAbsent(foods[i].name, () => [1,foods[i].calories]); + }else{ + resultMap[foods[i].name]![0] = resultMap[foods[i].name]![0] + 1; + } + } + return resultMap; +} \ No newline at end of file