I am using the provider package and have a provider that gets its initial value from a global variable idea which a list of json data and is of type List<Map<String, dynamic>>.
following is the code for that, which is working expected.
final ideasListProvider = StateNotifierProvider<IdeaList>((ref) {
return IdeaList([for (var i in ideas) Idea.fromJson(i)]);
});
Now what I am trying to achieve is replace the variable idea and instead use the list of documents I get from a collection I have on firebase.
But I am not sure how to proceed from here onwards.
Here's a second provider that fetches the snapshot form firestore.
final firbaseIdeaProvider = StreamProvider.autoDispose((ref) {
return FirebaseFirestore.instance.collection('ideas').snapshots();
});
What do I do now? The rest of my code is depended on the ideasListProvider, so I will have to somehow provide it with the a list of the documents from the ideas collection on firebase.