csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
441 stars 97 forks source link

Automatic Redirect with StreamProvider (instead of ChangeNotifier) #180

Closed kornha closed 2 years ago

kornha commented 2 years ago

Hello,

Great library, thank you so much!

I wanted to ask a question that I think would help a lot of firebase users. It can become simpler in firebase to use a StreamProvider instead of a ChangeNotifierProvider because _auth.authStateChanges(); returns a stream, thereby one can simply do thus:

  Stream<User?> get fbUser {
    return _auth.authStateChanges();
  }

However, I cannot quite figure how I might use this type of provider with redirect and refreshListenable. (Obviously I could abandon the StreamProvider, or intercept with a ChangeNotifier, but not ideal). Any thoughts?

csells commented 2 years ago

It would be easy to translate a stream of events into change notifications for a listenable implementation.