gpt4 book ai didi

flutter - Dart:使用Stream而不是Future进行Api调用

转载 作者:行者123 更新时间:2023-12-03 03:01:14 26 4
gpt4 key购买 nike

如何在Flutter中使用Stream函数而不是Future函数来进行API调用,而不是寻找StreamBuilder。

使用Future进行Api通话

Future<Post> fetchPost() async {
final response =
await http.get('https://jsonplaceholder.typicode.com/posts/1');

return response;
}

我想使用Stream做同样的功能

最佳答案

请 checkout dio http包

https://pub.dev/packages/dio

关于flutter - Dart:使用Stream而不是Future进行Api调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59302575/

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