如何使ListView.builder的itemCount等于FirebaseStorage中的照片数量?

时间:2020-03-10 18:13:37

标签: android ios android-studio flutter dart

These are my firebase storage images in its 'photos' folder

我正在尝试将在此存储中使用的图像流式传输到Flutter应用中。任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

我会这样:

Stream<QuerySnapshot> qs = Firestore.instance.collection('photos').snapshots();
int length = await qs.length;

答案 1 :(得分:0)

您可以使用StreamBuilder

Stream<QuerySnapshot> qs = Firestore.instance.collection('photos').snapshots();
return StreamBuilder<QuerySnapshot>(
    builder:(context,snapshot){
        if(snapshot.hasData){
          return ListView.Builder(
              itemCount:snapshot.data.documents.length,
              builder:(context,position)=>YOURVIEW()
          );
        }else
          return CircularProgreesIndicator();
    },
    stream:qs
);