首页 > 解决方案 > Flutter: app stops working whit image gallery on Android

问题描述

enter image description here

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

标签: flutterflutter-dependencies

解决方案


很可能您的图像具有高分辨率并且您的内存不足。Flutter 默认以全分辨率缓存图像,即使它们出现在小盒子中。您需要检查cacheHeightcacheWidth使用适当尺寸的图像。

并检查你的开发工具来监控性能——这是你最好的指标。


推荐阅读