leemuljadi
leemuljadi

Reputation: 470

How to use StreamProvider with minimal widget re-build and firestore read?

I want to StreamProvider to pass my UserData object through out all the widgets, so it can be accessible anywhere.

The UserData object is taken/read from the Firestore database.

My questions are:

  1. How can I use StreamProvider properly/efficiently so it will minimize the widget rebuild and read from Firestore (cause Firebase bills per every document read, CMIIW)?
  2. Should I use FutureProvider instead? But I want the UI also be able to be updated when there is change in the database.

Upvotes: 2

Views: 508

Answers (1)

isacjunior
isacjunior

Reputation: 492

With Provider, you can use Consumer and Selector to avoid unnecessarily rebuilds.

https://pub.dev/documentation/provider/latest/

Upvotes: 1

Related Questions