颤抖:类型'List <dynamic>'不是类型'String'的子类型

时间:2019-03-08 07:36:04

标签: dart flutter

我正在尝试从服务器接收的值中迭代数据。但是我遇到以下错误:

flutter: type 'List<dynamic>' is not a subtype of type 'String'

收到的数据是

{-L_Ct1pu8k2qeVEbaiwN: [{calorie: 0-30, food: {calorie: 0, carb: 0, fat: 0, image: https://firebasestorage.googleapis.com/v0/b/yourstrulycare.appspot.com/o/food_item_LN5T8kDMQEJtJ7KfAGQEiJXtLRBXcGksLrn8we4tN9mx9qqINz.png?alt=media&token=499fce97-4a70-4805-8e83-f5094043db13, key: -LSOFQCZGLMpFdgLvsu0, name: Warm water with Cinnamon, protien: 0, qty: 500, range: 0-30, uom: ml}, notes: 1, serving: 1, time: Pre-Breakfast, total_calorie: 0}, {calorie: 0-30, food: {calorie: 18, carb: 1, fat: 1.4, image: https://firebasestorage.googleapis.com/v0/b/yourstrulycare.appspot.com/o/food_item_w2nj0GCjlg5zsP7jisS45IY3XTyLZhoX5R9OAG7W55czyXFDbU.png?alt=media&token=024631ed-2912-4935-9476-2bde51dbc20d, key: -LSIyhpzxUYOrzf4lUwx, name: Flax Seeds, protien: 0.6, qty: 200, range: 0-30, uom: Gram}, notes: 1, serving: 1, time: Pre-Breakfast, total_calorie: 18}]}

我的代码是

      try{
        widget.mealData.forEach((key, value) {
          print('Value -----'+value);
          if (value != null)
            _mealList.add(MeanIntervalData.checkData(
              tempId: key,
              tempData: value,
            ));
        });
      }catch(error){
        print(error);
      }

它正在产生一个错误

flutter: type 'List<dynamic>' is not a subtype of type 'String'

我该如何迭代呢?

0 个答案:

没有答案