我收到此错误
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();
}
.....................
1条答案
按热度按时间3ks5zfa01#
你的输出是不匹配到模型类,第一检查你得到什么从API后你能到修正这错误