title: How to convert a Stream to a Listenable in Flutter?
body: <p>I am trying to figure out how to make use of Firebase's <code>onAuthStateChanges()</code> stream to use as a Listenable in the <code>refreshListenable</code> parameter from the <a href="https://pub.dev/packages/go_router" rel="nofollow noreferrer">go_router</a> package to redirect whenever the authState changes.
  In additon I am using <a href="https://pub.dev/packages/flutter_riverpod" rel="nofollow noreferrer">flutter_riverpod</a> for State Mangement.</p>
  <p>My code looks like this so far:</p>
  <p>I created a simple AuthService class (shrinked down to the most important parts):</p>
  <pre><code>abstract class BaseAuthService {
    Stream&lt;bool&gt; get isLoggedIn;
    Future&lt;bool&gt; signInWithEmailAndPassword({ required String email, required String password });
  }
  
  class AuthService implements BaseAuthService {
    final Reader _read;
  
    const AuthService(this._read);
  
    FirebaseAuth get auth =&gt; _read(firebaseAuthProvider);
  
    @override
    Stream&lt;bool&gt; get isLoggedIn =&gt; auth.authStateChanges().map((User? user) =&gt; user != null);
  
    @override
    Future&lt;bool&gt; signInWithEmailAndPassword({ required String email, required String password }) async {
      try {
        await auth.signInWithEmailAndPassword(email: email, password: password);
        return true;
      } on FirebaseAuthException catch (e) {
        ...
      } catch (e) {
        ...
      }
  
      return false;
    }
  </code></pre>
  <p>Next I created these providers:</p>
  <pre><code>final firebaseAuthProvider = Provider.autoDispose&lt;FirebaseAuth&gt;((ref) =&gt; FirebaseAuth.instance);
  
  final authServiceProvider = Provider.autoDispose&lt;AuthService&gt;((ref) =&gt; AuthService(ref.read));
  </code></pre>
  <p>As mentioned before, I would like to somehow listen to these authChanges and pass them to the router:</p>
  <pre><code>final router = GoRouter(
      refreshListenable: ???
      redirect: (GoRouterState state) {
          bool isLoggedIn = ???
          
          if (!isLoggedIn &amp;&amp; !onAuthRoute) redirect to /signin;
      }
  )
  </code></pre>