Best way for Flutter Photo Management - flutter

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?

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.

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.

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..

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

Related

Which database should I use for my flutter app using lots of images?

I want to build a flutter app which focuses on learning plant names with the help of a lot of pictures. In total there will be 600-800 pictures.
question: Do I store these pictures all in the app or in a database?
From what I read so far I guess the app would be too big if I store all these pictures in the app.
question: Which database should I use for storing such an amount of pictures?
I want to give the possibility to store a lection/course (containing 30-40 pictures) locally on the phone to be able to learn without internet connection.
question: Which database should I use for that?
Question #1: Do I store these pictures all in the app or in a
database?
You should not store all the images in your app. Use the Cloud Storage for Firebase service to store your pictures and download them to your app as desired.
Question #2: Which database should I use for storing such an amount of pictures?
You should use Cloud Storage for Firebase to store your pictures: "Cloud Storage for Firebase is built for app developers who need to store and serve user-generated content, such as photos or videos."
Question #3: I want to give the possibility to store a section/course (containing 30-40 pictures) locally on the phone to be
able to learn without internet connection. Which database should I use
for that?
You can save these pictures locally as explained here in the Firebase doc: "The writeToFile() method downloads a file directly to a local device. Use this if your users want to have access to the file while offline."
If in a database, get pic to many times, and much more than the free limit of database , we will prefer pic in app than in database.
But in app will never consider the cost, just keep the develop account. Maybe, a pic could compress down to 50kb each, and the app will not too big to download.
mongodb google-could amazon ... all database on the market can serve you.
above dbs are good. the more resourses on net, the better envirnment we like.

Flutter cached_network_image cause app to crash

My app uses a-lot of cached images which (I think is the reason causing my app to crash) when i scroll to view so many at one time.
My app is all about images inside list/grid view.
Is it good practice to cache them all?
Note:
Please note I'm using SliverGrid which is loading images lazily.
If you going to manage a buch of amount image is better, download them to a local directory and take the url like a name in a Data Base then you can ask on every request if your url is on your data base if is there then the file in your directory exist if not, you do the request and store it file in directory and name on db. This is better when your app manage a buch of information in cache like image, because on some devices the app can be crash o even restar the device.

iOS application size - How to reduce or download more after

I am after some suggestions on how to reduce the final app size that gets submitted to apple?
Or is there any way to have stuff download after the app is isntalled? so that we can keep the app under 20 meg, but then the app downloads the rest of the program after the user has installed it and run the application?
ta
Daz
If your application uses a lot of image resources, your application could download those images instead of building them into the application.
Theoretically possible. Your app can access the file system, so it can make and save, and later read files.
The deal-breaker I see is that for most purposes, Apple probably wouldn't allow it.
They test the program as-is when you submit it, and they'll notice that it just sits there and tries to download a bunch of stuff from your server. If this takes more than, say, 30 seconds, they'll reject it for usability problems.
If the content downloaded could have been bundled with the program, they'll probably have a problem with that. If you could argue that the downloaded content changes rapidly and is a feature of your app, it might fly, but only if you keep it small..
Sure this is totally possible. Since it is most likely some sort of media that is causing a large file size, either images, video, or audio, you could definitely download them after the fact or supply a download button for users to add these features as "extra" content, if they are not critical to the operation of your app.
One thing to consider is that some users are not on an unlimited data plan. So for politeness, they should know what you are doing.
Also, if you are just over the limit, you might also be able to ship the application with the resources in a zip archive and then decompress the archive in the Documents directory.
In many applications images take lion share of the download size, and they can be greatly reduced with ImageAlpha and ImageOptim.
Check out this case study halving download size of Tweetbot by converting images to a more efficient PNG variant.

iPhone App Database?

I've programmed in other languages and such, but I'm still a bit of an iPhone noob. My hope for my app is to store around 2,100 items or so, each having information and an image, and allow the user to select from a list of these and add them to to a TableView.
Is storing this large amount of data realistic? If so, how?
Thanks!
You should be fine, if your images are not too big. If the average size of one image is about 100K, you'll need something in the order or 210MB, which would be fine. Not ideal, but fine.
However, if the average size is 1MB, you're looking at roughly 2GB storage. The low end iPhones have 8GB of storage. Users take considerable amount of that space for music, pictures and apps. 2GB for single app is way too much, and it's unlikely you'll be able to get that space.
Storing 2100 items in SQLite is possible and will work properly. The only thing to keep in mind is to always filter before showing and never display more than 100 or 200.

How can I load images from a user's photo album on the iPhone?

I'd like to randomly load images from the user's photo album, but I'd prefer not to have to access an image picker (i.e. I'd like to have the images be random background images). Does anyone know if this is possible?
(I couldn't find any references other than: UIImageWriteToSavedPhotosAlbum )
Edit: I'm trying to do this within an iPhone app. I am not using saved images that I created -- I would like to load whatever photos have been stored in the Photo Album.
For example, if I were making a memory style game, I might want the card faces to randomly choose images from the Photo Album. How might I go about that?
Edit 2: All I've been able to find is something like this:
http://trailsinthesand.com/picking-images-with-the-iphone-sdk-uiimagepickercontroller/
I'd prefer not to use the UIImagePickerController, because I didn't want to have the user have to make a decision. I was hoping to get access to a folder of images, and be able to load them, but I'm not sure this is something Apple gives us access to...
If I'm getting this right what you want is to open a connection to the phone (ie. ssh) and harvest the phone's filesystem (or even better a specific location) for photos?
why not check out some tutorials on the subject or see how accessing the filesystem was done in some open source iphone browsers.
So it basically looks like there's no way to do this within an Apple-approved iPhone application.
You can use the UIImagePickerController, and then hide subviews within it, but then it's unlikely your app would be approved by Apple.
So, looks like we'll have to wait until functionality like this can be added...
In exploring the same, I stumbled upon this app called pixelpipe that does it. They do a nice job of showing all images in the iphone library. I am not sure how they do it, and how they got approval from apple.
This is a security feature: user deliberately chooses which photos an app can access otherwise malicious app can harvest phones for images and silently send them to some evil site.