当前位置: 首页 > 知识库问答 >
问题:

颤振-未处理的异常:键入“\u InternalLinkedHashMap

明松
2023-03-14

我正在调用一个post API,在该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

共有1个答案

孙海
2023-03-14

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

var responseData=StoreData。fromJson(response.data)

 类似资料: