Does listening to a stream using Provider works same as listening once in initState() without the Provider

29 Views Asked by At

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?

0

There are 0 best solutions below