android - 如何提高 `ListView.builder` 的性能?
问题描述
我有一个ListView.builder
从firebase构建视频的东西,它工作正常,但是当我上下很多次所以它重建时,视频抛出一个错误,我认为这是因为listview.builder,有什么想法可以防止这种情况吗?
代码
StreamBuilder(
stream: _store
.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 link = snapshot.data.documents[i].data['Link'];
var uploader = snapshot.data.documents[i].data['Uploader'];
var likes = snapshot.data.documents[i].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 link != null
? SingleChildScrollView(
child: Column(
children: [
Chewie(
controller: chewieController,
),
],
);
...
解决方案
推荐阅读
- facebook-graph-api - Facebook Graph - Instagram - “(#3) 应用程序必须在白名单中”
- java - java juint测试选择哪个delta以避免浮点错误
- tokenize - 如何有效地标记文本?
- laravel - 如何排除 .php 文件被 laravel mix 监视
- vb.net - 从文本文件中查找经过的时间
- c# - 字段名没有默认值
- spring-mvc - 发送除表单字段外的额外参数
- node.js - 如何使用 npm 链接启动带有快速服务器的包?
- sql - 为什么我不能将电子邮件正文存储在关系数据库中?
- django - django rest框架中的慢序列化