I'm try to get sub collection
from each doc ex.clothes,notifer
witch I have more docs , that means I don't know its id ,My bossiness Logic was to fetch the main collection
for getting all the documents
and then for each doc get its sub collection
and I did that with Future implementation ,but I can't do it using Stream to return the final Sub Collection SnapShots
ex.properitres
for listing to changes . by Future
it rebuild every time and if I stop widget rebuilding by AutomaticKeepAliveClientMixin
I could not get any Firesotre
changes . Thanks in advance .
here is my Future implementation but again I need this implementation by Stream ^_^:
Future<List<Category>> getPropertiesDocs() async {
List<QueryDocumentSnapshot> _firstListOfDocs = [];
List<Category> _categorListOfDocs = [];
List<QueryDocumentSnapshot> _secoudListOfDocs = [];
final QuerySnapshot result = await _firebaseFirestore.collection('categories').get();
result.docs.forEach((element) {
// print(element.id);
_firstListOfDocs.add(element);
});
for (var i in _firstListOfDocs) {
final QuerySnapshot snapshot2 = await i.reference.collection("properties").get();
snapshot2.docs.forEach((element) {
_secoudListOfDocs.add(element);
_categorListOfDocs.add(Category.fromSnapShpt(element));
});
}
_firstListOfDocs.clear();
_secoudListOfDocs.clear();
return _categorListOfDocs;
}