gpt4 book ai didi

dart - 获取 _InternalLinkedHashMap' is not a subtype of type ' FutureOr'

转载 作者:IT王子 更新时间:2023-10-29 07:13:01 26 4
gpt4 key购买 nike

我是 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/

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