如何建立带有抖动和火力的视频列表?

时间:2020-09-04 06:03:37

标签: flutter video google-cloud-firestore

我是不熟悉Flutter的人,我想用Flutter和Firebase建立一个视频列表,因此,我用ListView.builder()构建了它,它可以正常工作,但是您知道ListView.builder()仅可以构建屏幕上的内容因此,如果我向下滚动并希望看到某些内容,它将重建,我不希望它重建。

代码

return StreamBuilder<Object>(
        stream: Firestore.instance
            .collection('Khatma Collection')
            .document('Khatma 1')
            .collection('Videos')
            .snapshots(),
        builder: (context, AsyncSnapshot snapshot) {
          if (snapshot.hasData) {
            return ListView.builder(
              shrinkWrap: true,
              itemCount: snapshot.data.documents.length,
              itemBuilder: (context, i) {
                var rng = new Random();
                int ii = rng.nextInt(4);
                if (ii == iii) {
                } else {
                  iii = ii;
                  var link = snapshot.data.documents[ii].data['Link'];
                  var uploader = snapshot.data.documents[ii].data['Uploader'];
                  var likes = snapshot.data.documents[ii].data['Likes'];
                  var like = likes.toString();
                  bool liked;
                  if (int.parse(like) > 0) {
                    liked = true;
                  } else if (int.parse(like) == 0) {
                    liked = false;
                  }
                  final videoPlayerController =
                      VideoPlayerController.network(link);
                  chewieController = ChewieController(
                    allowMuting: true,
                    autoInitialize: true,
                    deviceOrientationsAfterFullScreen: orientation,
                    allowFullScreen: true,
                    aspectRatio: 16 / 9,
                    videoPlayerController: videoPlayerController,
                  );
                  return SingleChildScrollView(
                    child: Column(
                      children: [
                        Chewie(
                          controller: chewieController,
                        ),
                        ),
                      ],
                    ),
                  );
                }
              },
            );
          }
        },
      ),
    

0 个答案:

没有答案