Combining Snapshot Firestore in Flutter

Hello everyone, it's novermber now. It's almost the end of year. So Many things happened in this year. I learned a lot. And for this article I want to share about something that I just know. It's very helpful for me to use this technique. 

The reason why I need to combine the snapshot, it's because I need to optimize showing data in the app. Before I just show all of data to be shown by users and it's not good to do it if you have many data. It makes your app slow because firebase has limitation time to show many data I check by myself. And It cost me a lot as well to show many data that I think it's ugly.

So one thing I need to figure it out is using this technique that I found on the internet. Because in firestore as well you cannot query where two times with same field. I think what you can do is using two snapshot and combining it.

Lucikly you can do it in flutter and I am happy because it works and made my app running fast when loading data. So Here's the code the important thing you need to notice is import async to use the combining function. I do the combination in repository layer.

And in presentation layer I need to use list to combine the snapshot again, because the data object is still DocumentSnapshot . And taraa just like that you have combined the snapshot and I hope it will make your app faster and cost your app lower. Thanks for visiting my simple blog. 


Popular posts from this blog

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android

Fixing Keyboard Hide When Reload UITableview iOS swift 5