Home > Software design >  Best way to cache pictures in flutter app?
Best way to cache pictures in flutter app?

Time:04-07

I have created an app using dart/Flutter where users are able to store photos. These photos are stored in FireStorage but every time the app opens it takes a while until all photos are loaded due to the large resolution of the pics. So, I was thinking if its better for every user to store locally the pictures and every time he/she opens the app to download only the new ones and not every photo.

In order to do this, I thought using HiveDB but I wanted to know first if there is any better solution than hivedb or any common practice for caching data. Do you think the approach of caching such a vast amount of pictures is a bad idea in general (i.e. takes too much space on users smartphone). Any suggestions are welcome.

CodePudding user response:

You can use this package Cached network image

CachedNetworkImage(
        imageUrl: "http://via.placeholder.com/350x150",
        progressIndicatorBuilder: (context, url, downloadProgress) => 
                CircularProgressIndicator(value: downloadProgress.progress),
        errorWidget: (context, url, error) => Icon(Icons.error),
     ),

CodePudding user response:

Check flutter cookbook demonstrates image catching with cache_network_image plugin

  • Related