[英]Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
I'm getting this error我收到这个错误
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>
popular_product_controller.dart:30:71 popular_product_controller.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:food_app/pages/splash/splash_page.dart:25:5 package:food_app/pages/splash/splash_page.dart:25:5
Future<void>_loadResource() async {
await Get.find<PopularProductController>().getPopularProductList();
await Get.find<RecommendedProductController>().getRecommendedProductList();
}
..................... ......................
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
your output is not matching to model class, 1st check what you get from api after you able to fix this error您的 output 与 model 不匹配 class,在您能够修复此错误后,首先检查您从 api 获得的内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.