From the state changes point of view and firebase cost, does using
data = Provider.of<MyModel>(context);
Or maybe Consumer() in build method, with a StreamProvider. works same as
@override
void initState() {
data = readDataFromFirestore(); // Listening my Stream here and using in build method
super.initState();
}
static Stream<MyModel> readDataFromFirestore() async* {
// stream code here
}
and then use StreamBuilder in build method.
What if we have multiple listeners of same stream. What is the best practice from firestore cost and optimisation point?