大佬教程收集整理的这篇文章主要介绍了无法从 DIO Flutter 中获得未来价值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 Flutter 编程的新手。我在尝试从 Future 获取价值时遇到了问题。拿到后想反序列化做进一步处理。
Future 的返回值在 JsON 数组上。
我应该怎么做才能解决这种情况?
@H_772_7@class _MyAppState extends State<BodyWidget>
{
bool loading = true;
List<Widget> ListArray = [];
dio dio = new dio();
dynamic isicontent = null;
Future<dynamic> getorderHistory() async {
final String pathUrl = "http://p.q.r.s/mobile/QIXGetShipmentHistory/" + await FlutterSession().get("MobileUsername");
var responsedio = await dio.get(pathUrl,options: Options( headers: {'Content-Type': 'application/Json; charset=UTF-8' } ) );
print(responsedio.data); // It's works fine here...
return responsedio.data;
}
voID renderIconShipmentOrderHistory()
{
var resultRespon = getorderHistory();
print(resultRespon); //the problem is here...
}
}
return
语句需要返回一个 Future
;类似的东西:
return dio.get(
pathUrl,options: Options(
headers: {
'Content-Type': 'application/json; charset=UTF-8'
}
)
)
签名中的 async
关键字可能可以删除,因为没有更多的 await
。
显然,不返回 Future
而等待结果可能是另一种选择。
以上是大佬教程为你收集整理的无法从 DIO Flutter 中获得未来价值全部内容,希望文章能够帮你解决无法从 DIO Flutter 中获得未来价值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。