I am currently developing an e-commerce app in Flutter which is using Firebase as a backend. I have some concerns and confusion regarding the cloud firestore therefore I need your help.
Some of the problems that I am facing are:
- Let's say I have 1000's of products in my collection which I gradually want to load when the user runs and scroll through the app, the problem is each time the user quits and runs the app again, the database is called again for the same data which I have already served and eventually costs me more reads.
I don't know how to deal with this situation and I can't find a proper solution too.
I want a way to load the product once and save it on users' memory so that next time when a user runs the app, at first it tries to load from the cache and after that query, the server for more data and again saves that to the cache.
I just want the app to listen and update the cache only when there are some changes in the database, like if I change the price or maybe title of the product. I don't want to fetch every time user runs the app.
My simple question is whats the efficient way to manage this type of situation in Flutter? Please help me and provide some guidance on this issue.
If there are any videos or blog articles that you think will help me with this situation please kindly mention them as well.