Hello im new to firebase.
I have 3 collections
Users: - userid
Providers: - Providerid - providerName - providerEmail
FavoriteProvider: - docId(userId+providerId) - userId - providerId
So, i have succeed put a favorite provider for a user and the user can have many favorite providers.
But how to get a stream list of favorite providers of that user in one list.
I tried using this code
Stream<List<SerProviders>> get favoriteProviders{
favoriteProvidersCollectionRef.where('userId', isEqualTo: uid).snapshots.map(providerListfromsnapshot)
}
The function providerListfromssnapshot
returns a list of providers according to model a created in flutter.
List<SerProvider> providerListfromssnapshot(QuerySnapshot snapshot) {
Return snapshot.docs.map((doc){
Var data = doc.data() as Map<String, dynamic>;
Return SerProvider(
ProviderId: doc.id,
ProviderName: data['providerName']
);}).toList();
}
But no idea how to complete.
I need the data of the provider (id and name) in that stream.
Anyone help me plzzz