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
Answer
Most likely your images are of high resolution and you are running out of ram. Flutter by default caches images at full resolution even if they appear in small boxes. You need to check things like cacheHeight
and cacheWidth
and use appropriate size images.
And check your dev tools to monitor performance- it's your best indicator.
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?