【发布时间】:2020-04-27 13:51:20
【问题描述】:
查看代码:
final ref = FirebaseStorage.instance.ref().child('Posts');
ref.listAll().then((result) {
print("Hello: ${result}");
所以,在我的 FirebaseStorage 中,我创建了一个名为“Posts”的文件夹,并在其中手动上传了一些图片。现在我不知何故发现了如何打印 Posts 文件夹中的所有数据。
查看输出:
{prefixes: {}, pageToken: null, items: {header_of_grace_and_beauty_in_summer.jpg: {bucket: hello-465d1.appspot.com, path: /Posts/header_of_grace_and_beauty_in_summer.jpg, name: header_of_grace_and_beauty_in_summer.jpg}, header_of_style_statement_with_valvet.jpg: {bucket: hello-465d1.appspot.com, path: /Posts/header_of_style_statement_with_valvet.jpg, name: header_of_style_statement_with_valvet.jpg}, header_of_dazzling_monsoon.jpeg: {bucket: hello-465d1.appspot.com, path: /Posts/header_of_dazzling_monsoon.jpeg, name: header_of_dazzling_monsoon.jpeg},
所以,你可以看到有 Prefix、PageToken、items、bucket 和 name n 所有。我想要这个列表中的 name 和 getDownloadUrl。
我该怎么做?
至少有人可以给出答案并打印那些东西?我试过了,但它没有发生。
编辑:
//Get 'Posts' stream
Stream<List<PostData>> get posts {
ref.listAll().then((value) {
print('VAL: $value');
return value;
});
}
这样我就可以这样访问了:
final posts = Provider.of<List<PostData>>(context) ?? [];
pri("VALUE:-> $posts");
【问题讨论】:
标签: flutter