Flutter-Ernaehrungsapp/lib/android/config/cast_helper.dart

24 lines
556 B
Dart
Raw Normal View History

import '../models/food.dart';
2023-05-29 22:04:44 +02:00
List<Food> castDynamicToListFood(dynamic dynamicList) {
List<Food> foodList = [];
2023-05-29 22:04:44 +02:00
if(dynamicList == null){
return foodList;
}
for (Food element in dynamicList) {
foodList.add(element);
}
return foodList;
}
Map<String,List<Food>> castDynamicMap(dynamic dynamicMap){
Map<String,List<Food>> foodMap = {};
if(dynamicMap == null){
return foodMap;
}
for(dynamic key in dynamicMap.keys){
foodMap.putIfAbsent(key as String , () => castDynamicToListFood(dynamicMap[key]));
}
return foodMap;
2023-05-29 22:04:44 +02:00
}