flutter - Flutter: app stops working whit image gallery on Android
问题描述
I have this gallery built with CachedNetworkImage
widgets and I uploaded some images from https://unsplash.com/. These images have good quality, so some of them are quite heavy.
Despite Flutter manages the images on an efficient way (when they are not presented on screen it doesn't display them) something weird happens.
As soon as I moved to the screen the app get closed and the phone's UI is reset. All the favourite icons I have at the bottom of the phone like contacts, whatsapp, etc. are disappeared and after a few seconds they start appearing again. Never saw this before with other apps.
I'm testing with the production version, not testing on my phone or using the simulator. Android emulator and iOS and simulator are fine
解决方案
很可能您的图像具有高分辨率并且您的内存不足。Flutter 默认以全分辨率缓存图像,即使它们出现在小盒子中。您需要检查cacheHeight
并cacheWidth
使用适当尺寸的图像。
并检查你的开发工具来监控性能——这是你最好的指标。
推荐阅读
- angular - 使用角度材料以角度在两个表之间传输行数据
- ssms-2014 - 简单表中的最大字符长度已更改。为什么?
- jquery - 如何使用 Jquery 在不同的 div 中显示月份选择器
- php - 对 Web 服务的 SOAP 请求问题
- crystal-lang - Crystal lang 错误:“找不到 -lssl 的库”
- c# - 使用带有“WindowsAzure.ServiceBus”nuget 的 azure servicebus 主题的共享访问连接字符串发送消息时出错
- ios - 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“此编码器要求从 initWithCoder 返回替换的对象:”
- homebrew - Homebrew 不升级 pyenv
- python - 使用 Kmeans 在矩阵线上建立聚类
- json - 我需要一个 json 文件的属性,但我的代码将它们全部提取出来