【发布时间】:2018-12-24 01:22:51
【问题描述】:
我尝试编写一个常见的 POST 请求方法,但它低于错误
Future<dynamic> requestMethod() async {
var url = "https://testurl";
var body = json.encode({"program_id":"1211"});
Map headers = {
'Content-type' : 'application/json',
'Accept': 'application/json',
};
var response =await http.post(url, body: body, headers: headers);
final responseJson = json.decode(response.body);
print(responseJson);
return response;
}
错误
Unhandled exception: E/flutter (24453): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, String>' E/flutter (24453): #0 NetworkUtil.requestMethod (package:fitnessstudio/globals.dart:76:61) E/flutter (24453): <asynchronous suspension>
【问题讨论】:
-
哪行代码导致错误?你能从堆栈跟踪中提供更大的部分吗?请添加
flutter doctor的输出 -
未处理的异常:E/flutter (24453): type '_InternalLinkedHashMap
' 不是类型 'Map ' E/flutter (24453): #0 NetworkUtil.requestMethod (package:fitnessstudio/globals.dart:76:61) E/flutter (24453): -
这是错误它的响应初始化错误或http post错误
-
package:fitnessstudio/globals.dart:76:61 的代码行是什么?
-
这是我赢得的代码写在这里我解决了这个问题非常感谢你的重播