向上/向下滚动时,ListView滞后 [英] ListView lagging while scroll up/down

查看:119
本文介绍了向上/向下滚动时,ListView滞后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道问题出在我的代码中还是在ListView中.在此处中查看我的 Final(已编辑)代码.

I don't know if the problem is in my code or in the ListView. Check out my Final(Edited) code here.

我正在分页.当我到达最后一页并向上/向下滚动ListView时,滚动变得迟钝了.我认为可能因为这一行而发生.

I'm working with pagination. When I reach the last page and scroll up/down the ListView the scrolling got laggy. I thought it might be happening because of this line.

    leading: CircleAvatar(backgroundImage: NetworkImage(arrayOfProducts[index]['thumbnail'] ?? "")),

NetworkImage可能需要一些时间来加载图像.不确定,但我认为滞后是由它引起的.因此,我添加了新软件包 cached_network_image ,并将代码更改为:

NetworkImage might be taking time to load the image. Not sure but I think the lag is being caused by it. So I added new package cached_network_image and changed my code to:

    leading: CircleAvatar(child: CachedNetworkImage(
                      imageUrl: arrayOfProducts[index]['thumbnail'] ?? "",
                      placeholder: new CircularProgressIndicator(),
                      errorWidget: new Icon(Icons.error),
                    )),

但是它仍然很慢,滚动时现在隐藏了以前的图像.

But it's still laggy and previous images are now being hidden while scrolling.

推荐答案

在使用图像时,这是Flutter中的已知问题:指向问题的链接.

This is currently a known issue in Flutter when using images: Link to Issue.

这篇关于向上/向下滚动时,ListView滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆