0

I have three categories each one in a separate collection I want to display them in one list by order them by time on the home page? how to do that with firestore and flutter

 Future<List<Event>> fetchEv() async {
    var snap =
        await evRef.orderBy('createdAt', descending: true).getDocuments();
    return convertToEvModel(snap);
  }
  Future<List<Ads>> fetchAd() async {
    var snap =
        await adRef.orderBy('createdAt', descending: true).getDocuments();
    return convertToAdModel(snap);
  }

  Future<List<Post>> fetchUserPosts() async {
    var snap = await postRef
        .orderBy('createdAt', descending: true)
        .where('creator', isEqualTo: this.userId)
        .getDocuments();
    return convertToPostModel(snap);
  }

i want to merge these three to one list

ha'az
  • 1
  • 1
  • It'll be easier for us to answer your question if you provide your code here. – Hussam Mar 21 '20 at 12:21
  • If you're trying to show them in a widget, see https://stackoverflow.com/questions/59061225/how-do-i-join-data-from-two-firestore-collections-in-flutter – Frank van Puffelen Mar 21 '20 at 14:43
  • @FrankvanPuffelen wow it seems very cool but I'm new actually can you show to me how to do it with my code and thank you very much – ha'az Mar 21 '20 at 20:10

0 Answers0