Reputation: 127
I have a Class I use for backend, within which I have a Stream that Streams data from Firebase, as shown below. I need to access the data from a Riverpod Provider to specify the Firebase collection reference (yearFromProvider2). How can this be done from within a Class that does not have any access to ref or context.
Stream<DocumentSnapshot> userStream() async* {
//Need to read another Stream here to access the value of year to add to collection reference
yield* FirebaseFirestore.instance
.collection(yearFromProvider2)
.doc("test")
.snapshots();
}
In all other parts of my app I would use StreamProvider and call it as follows:
final data = ref.watch(provider).value;
This cannot be done within the Class as I do not have any access to Ref or the BuildContext. Is there any quick solution to read an instance of the Provider2?
Upvotes: 1
Views: 108