作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我是 Dart/Flutter 的新手,我正在尝试获取使用网络服务的 future 结果:
Future<Map> _readData() async {
(...)
http.Response response = await http.post(
request,
headers: {
"SOAPAction": "http://www.totvs.com/IwsConsultaSQL/RealizarConsultaSQL",
"Content-Type": "text/xml;charset=UTF-8",
"Authorization": "Basic bWVzdHJlOnRvdHZz",
"cache-control": "no-cache"
},
body: utf8.encode(requestBody),
encoding: Encoding.getByName("UTF-8")
).then((onValue){
(...)
var dataFinal = jsonDecode(jsondataFinal);
return dataFinal ;
});
在我的初始状态下,我调用了这个函数,所以我可以使用这个结果来构建我的布局:
@override
void initState () {
super.initState();
_readData().then((data){
setState(() {
print(data);
});
});
}
我总是得到这个异常(exception):
_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'FutureOr<Response>'
对我做错了什么有什么想法吗?
谢谢
最佳答案
此代码是否出现此错误?
Future<Map> _readData() async {
//...
http.Response response = await http.post(
request,
headers: {
"SOAPAction": "http://www.totvs.com/IwsConsultaSQL/RealizarConsultaSQL",
"Content-Type": "text/xml;charset=UTF-8",
"Authorization": "Basic bWVzdHJlOnRvdHZz",
"cache-control": "no-cache"
},
body: utf8.encode(requestBody),
encoding: Encoding.getByName("UTF-8")
);
//...
var dataFinal = jsonDecode(jsondataFinal);
return dataFinal ;
}
关于dart - 获取 _InternalLinkedHashMap<String, dynamic >' is not a subtype of type ' FutureOr<Response>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53651294/
我是一名优秀的程序员,十分优秀!