Epsi95
Epsi95

Reputation: 9047

Best way for Flutter Photo Management

I am creating an app where the user will select some photos for the avatars used in the app. Once selected, on the next launch I want to populate the avatars automatically.

Solution I am Thinking: I will keep a duplicate of the original photo in the app directory and next time I will use the photo to make the avatars.

Issue: Not efficient as the same copy of the image exists.

Question: Since many apps are doing this thing, I want to know the best way to do that, more specifically in Flutter?

Upvotes: 1

Views: 1162

Answers (4)

Michel Feinstein
Michel Feinstein

Reputation: 14286

Use the cached_network_image plugin.

This plugin allows you to download an image from the internet and cache it in the app for later. You can provide a placeholder image that sits there while no image has been loaded yet(from the web or the internal cache) and also what to show in case of error. If the device goes offline cached_network_image automatically will load the image from the cache, it's transparent to your app, you don't have to bother with the cache, storage space, database, anything.

Take a look at the docs.

Upvotes: 2

Khalifa Alkhatri
Khalifa Alkhatri

Reputation: 294

use cached images widget to store images for some time or use SQLite database for long time in device .

Upvotes: 0

Tom O
Tom O

Reputation: 2645

There are no best practices in this regard. It depends on your app.

1) Storing your avatars

Takes more storage space. But your app runs faster.

Best when the number of avatars displayed on a single screen is high, but the total number of avatars in your app is small. (E.g.: you show 15 avatars on a single screen, and there are 100 avatars in your database).

2) Generating your avatars

Takes less space. But your app runs slower.

Best when the number of avatars displayed on a single screen is low, but the total number of avatars in your app is large. (E.g.: you only show 3 avatars on a single screen, but there are 100.000 avatars in your database).

Conclusion

Speed is usually more important than storage space, therefor I'd lean towards storing the avatars. But the only true way to get an answer is to test it and see what works best for your specific app.

Upvotes: 1

Erkan
Erkan

Reputation: 766

I think you must copy the original photo, Most people use cloud service(google photos etc.) for their photos and not keep photos on phones any more..

Upvotes: 0

Related Questions