gpt4 book ai didi

Flutter - 未处理的异常 : type '_InternalLinkedHashMap

转载 作者:IT王子 更新时间:2023-10-29 06:39:07 24 4
gpt4 key购买 nike

我正在调用一个 post API,我必须在其中发送 FormData 但在收到响应后,当我尝试解析该响应时,我遇到了异常。

static Future<String> versionApiRequest(String storeId, String deviceId) async {
String versionApi = 'https://xxxxxxx/${storeId}/api_v5/version';
print('$versionApi , $storeId');

FormData formData = new FormData.from(
{"device_id": deviceId, "device_token":"", "platform":"android"});
Dio dio = new Dio();
Response response = await dio.post(versionApi, data: formData,
options: new Options(
contentType: ContentType.parse("application/json")));
print(response.data.toString());

StoreData storeData = storeDataFromJson(response.data);
//print("-------store.success ---${storeData.success}");
return "";
}

我遇到以下错误:

Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
#0 ApiController.versionApiRequest (package:restroapp/src/networkhandler/ApiController.dart:43:54)
<asynchronous suspension>

下面是我的模型类 https://gist.github.com/achinverma/641774f50d27b2f4f5be9f1c341f0fc2

最佳答案

将此更改为将响应映射到您的模型类

var responseData = StoreData.fromJson(response.data);

关于Flutter - 未处理的异常 : type '_InternalLinkedHashMap<String, 动态>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57456086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com