Android Studio 未处理的异常:类型"_InternalLinkedHashMap〈String,dynamic>"不是类型"String"的子类型

cig3rfwq  于 2023-01-05  发布在  Android
关注(0)|答案(1)|浏览(199)

我收到此错误

2023-01-04 15:05:33.297 15984-16060/com.example.food_app E/flutter: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
    #0      PopularProductController.getPopularProductList (package:food_app/controllers/popular_product_controller.dart:30:71)
    <asynchronous suspension>
    #1      _SplashScreenState._loadResource (package:food_app/pages/splash/splash_page.dart:25:5)
    <asynchronous suspension>
    • 流行的产品控制器。dart:30:71**
Future<void> getPopularProductList()async {
    Response response = await popularProductsRepo.getPopularProductList();
    if(response.statusCode==200) {
      _popularProductList =[];
      _popularProductList.addAll(Product.fromJson(jsonDecode(response.body)).products);
      _isloaded=true;
      update();
    }else{
    }
  }
    • Package :食品应用程序/页面/飞溅/飞溅页面。dart:25:5**
Future<void>_loadResource() async {
    await Get.find<PopularProductController>().getPopularProductList();
    await Get.find<RecommendedProductController>().getRecommendedProductList();

  }

.....................

3ks5zfa0

3ks5zfa01#

Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

你的输出是不匹配到模型类,第一检查你得到什么从API后你能到修正这错误

相关问题