gpt4 book ai didi

image - 如何在我的 flutter 应用程序中从 bing web search apiv7 获取图像

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

如何使用 Bing 网络搜索 Apiv7 在我的 flutter 应用程序中获取照片?

我从官方网站获得了 API 和端点,但我无法获取 JSON 文件以在项目生成器子项中调用它。

示例子:new Image.network('${data['value']['webSearchUrl']}'
我不知道在这个 child 身上放什么以及在哪里放 API key ......

class _PageOneState extends State<PageOne> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: new FutureBuilder(
future: getPics(),
builder: (context, snapShot){
Map data = snapShot.data;
if(snapShot.hasError){
print(snapShot.error);
return Text('Failed to get data from server',
style: TextStyle(color: Colors.red,
fontSize: 22.0),);
}else if(snapShot.hasData){
return new Center(
child: new ListView.builder(
itemCount: data.length,
itemBuilder: (context, index){
return new Column(
children: <Widget>[

new Container(
child: new InkWell(
onTap: (){},
child: new Image.network(
'${data['value']['webSearchUrl']}'
),
),
),
new Padding(padding: const EdgeInsets.all(5.0)),
],
);
}),
);

}
else if(!snapShot.hasData){
return new Center(child: CircularProgressIndicator(),);
}
}
),

);
and below the code -


Future<Map> getPics() async{
String url =
'https://api.cognitive.microsoft.com/bing/v7.0/images';
http.Response response = await http.get(url);
return json.decode(response.body);
}

最佳答案

webSearchUrl指向一个带有搜索结果的网页,这就是它在 Image.network() 内不起作用的原因.试试改成contentUrl对于完整的图像你;来自第三方网站或 thumbnailUrl对于 bing 托管的小缩略图 url。

关于image - 如何在我的 flutter 应用程序中从 bing web search apiv7 获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54747760/

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