import '../models/food.dart'; List castDynamicToListFood(dynamic dynamicList) { List foodList = []; if(dynamicList == null){ return foodList; } for (Food element in dynamicList) { foodList.add(element); } return foodList; } 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])); } return foodMap; }