Flutter Listview从视频URL加载缩略图图像时崩溃,我的应用程序崩溃了

问题描述 投票:0回答:1

我尝试滚动列表时从视频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
1个回答
0
投票

如何将这项工作专用于云上运行的NGINX / NodeJS服务?让该应用程序从中下载缩略图。这是我以前所做的。

© www.soinside.com 2019 - 2024. All rights reserved.