【发布时间】:2020-02-09 18:42:45
【问题描述】:
当我的列表滚动时,我尝试从视频 url 获取图像,但是当我使用视频缩略图库并在我的应用程序列表中调用它时冻结并且我的应用程序崩溃了,这是我的代码
Future _loadMore(context) async {
final diractory=Provider.of<DiractoryPath>(context,listen: false);
Provider.of<LoadState>(context).setLoadState(true);
final index= Provider.of<IndexLazyloading>(context);
if(moves.length!=index.oldmove){
resetlist(context);
}
// Add in an artificial delay
for (var i = index.currentindex; i <= index.currentindex + increment && i<moves.length; i++) {
File f=new File( "${diractory.diractory}/${moves[i].videourl.split("/").last.replaceAll("mp4", "png")}");
if(!f.existsSync())
await getimage("${strings.baseurl}/videos/${moves[i].videourl}",context);
index.setdata(i);
}
await new Future.delayed(const Duration(seconds: 2));
Provider.of<LoadState>(context).setLoadState(false);
index.setcurrentIndex(index.data.length) ;
index.setoldMove(moves.length);
}
这是我使用的插件
Future<Null> getimage(videourl,context)async{
final uint8list = await VideoThumbnail.thumbnailFile(
video: videourl,
thumbnailPath: Provider.of<DiractoryPath>(context).diractory,
imageFormat: ImageFormat.WEBP,
maxHeightOrWidth: 0, // the original resolution of the video
quality: 75,
);
}
我尝试使用 png 但不起作用 这是我调用此函数的列表,此代码有什么问题,请帮助我
LazyLoadScrollView(
isLoading: loadstate.isload,
onEndOfPage: () => _loadMore(context),
child: ListView.builder(
itemCount: indexlayze.data.length,
itemBuilder: (context, position) {
return _buildProductItem(context,position);
},
));
我的列表在到达列表末尾时会获得 10 个图像缩略图,但如何处理它非常慢
【问题讨论】:
标签: android listview flutter thumbnails