My app has a collection of cards and I need to add some car to the favorites list, and I would like that each user has its own favorites collection.
So I did the classic StreamBuilder sample to show some list on Flutter:
StreamBuilder<QuerySnapshot>(
stream: getCars()
If the getCars() function is like this, everything is ok:
getCars() {
return Firestore.instance
.collection("users")
.document("oT646MvXXXXXXXXXXXjlN8L1V2")
.collection("cars").snapshots();
}
Let's say that "oT646MvXXXXXXXXXXXjlN8L1V2" is the FirebaseUser uid.
But how can I read FirebaseUser uid dinamically to return the collection?
I tried this code but it didn't work, since it returns a Future:
getCarsError() async { FirebaseUser fUser = await FirebaseAuth.instance.currentUser();
return Firestore.instance
.collection("users")
.document(fUser.uid)
.collection("cars").snapshots();
}
How can I acompplish that?
thank you