【发布时间】:2021-07-23 02:03:27
【问题描述】:
我想通过存储在 Firebase firestore 中的 url 显示带有索引的图像,我正在获取存储在云存储中的图像,但我不知道如何获取存储在数组中的 firebase firestore 中的 url。请帮助我,因为我只是一个初学者并通过互联网学习。图片附在下面。 提前致谢。
List<String> urls = [];
@override
void initState() {
super.initState();
_getImages();
}
这是通过存储在云存储中的 url 显示图像的容器。
Container(
height: 160.0,
padding: EdgeInsets.symmetric(vertical: 15.0,horizontal: 15.0),
child: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: <Widget>[
SliverPadding(
padding: const EdgeInsets.all(10),
sliver:
_buildContent(urls),
)
],
),
),
这是我将图像存储在云存储中的方法。
_getImages() async {
ListResult _result = await _stoarge.ref().child("images").list(ListOptions(maxResults: 10));
_result.items.forEach((_ref) async {
String _u = await _ref.getDownloadURL();
urls.add(_u);
setState(() {
print(urls.length);
print(urls);
});
});
}
【问题讨论】:
标签: firebase flutter google-cloud-firestore