flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

[FR] Use hive + file system instead of sqflite as the storage layer.

Open actow opened this issue 3 years ago • 3 comments

The sqflite plugin has many downsides, platform dependent, not available on all platform to name a few.

Hive key-value stored built with pure dart. So it's available on all platforms supported by Flutter. It's also very light weight and fast, perfect for the image caching case.

actow avatar May 18 '21 16:05 actow

Hive is a memory storage. Because of this fetching one image will put all 'box' (all images in box) in memory. You can store one image in one box, but it will be just simple file-per-image storage. Has no reason to use Hive in this way. I think better solution will be caching in files. I don't know why SQLite used for files now.. Its just overhead.

NaikSoftware avatar Oct 21 '21 09:10 NaikSoftware

@NaikSoftware, Actually, Hive load the boxes in memory but persist them on the disk. One box, can contain several images. This could help achieve severals requested feature like multiple size by images, use a smaller image as placeholder...

But to save them into a box they would have to be Uint8List... So probably only the path to the image would be saved.

bounty1342 avatar Nov 11 '21 01:11 bounty1342

@bounty1342 Hive read boxes in main (UI) isolate. It cause lags and frame drops when you try to read box larger than 1-2Kb (depending on device you use). Move Hive to another isolate will have overhead. Much better solution is using any object database.

NaikSoftware avatar Nov 16 '21 09:11 NaikSoftware