I am working on a flutter project and building a page where we have image folders as dropdown menu and as we select one, the page should display all the images present in that folder.
I have achieved this using platform channels, but the problem is, I am trying to load all those images in a GridView using Image.file(), and it loads all those images very very slow and the whole UI freezes.
How to fix it and make it smooth?
            Asked
            
        
        
            Active
            
        
            Viewed 1,246 times
        
    7
            
            
         
    
    
        Hitesh Garg
        
- 71
- 4
- 
                    2to show Images use `FadeInImage` widget - https://docs.flutter.io/flutter/widgets/FadeInImage-class.html – anmol.majhail Feb 19 '19 at 13:03
- 
                    @anmol.majhail Image.file() can't be used inside FadeInImage() widget! – Hitesh Garg Feb 19 '19 at 13:39
- 
                    use - `FileImage()` in `FadeInImage`. https://docs.flutter.io/flutter/painting/FileImage-class.html – anmol.majhail Feb 19 '19 at 13:43
1 Answers
-1
            
            
        It's likely that your app hits its allocated memory. Out of Memory error is thrown because the images being displayed and cached are full-sized images that are most likely resized (still takes a chunk of memory). I suggest generating thumbnails for the images that you'll display to save memory. There are a lot of helpful answers on this post that you can choose from.
If you're just using the Image GridView as an image picker, you may want to consider using image_picker plugin as an option.
 
    
    
        Omatt
        
- 8,564
- 2
- 42
- 144