title: What is the RiverPod way to Consume a StreamProvider outside of Flutter - Dart only
body: <h3>Working with RiverPod for first time and the Provider concept in general.</h3>
  <p><strong>Goal:</strong> Validate the signed in user has an account info <strong>document</strong> in my <em>accounts</em> FireStore <strong>collection</strong>.</p>
  <p>My code is based off this <a href="https://github.com/bizz84/starter_architecture_flutter_firebase/tree/91e930280ad5dd2adda90a6f5fb3a7e78934b06b" rel="nofollow noreferrer">flutter/firebase starter architecture</a> referenced on the <a href="https://riverpod.dev" rel="nofollow noreferrer">RiverPod</a> site as an example of how to use RiverPod for state management.</p>
  <p>I'm using latest <a href="https://pub.dev/packages/flutter_riverpod" rel="nofollow noreferrer">flutter_riverpod</a> package.</p>
  <h3>My minimized code:</h3>
  <p><em>firestore_database.dart - implementing model/service layers away from ui.</em></p>
  <pre><code>Stream&lt;Account&gt; accountStream() =&gt; _service.documentStream(
          path: FirestorePath.account(uid),
          builder: (data, documentId) =&gt; Account.fromMap(data, uid),
        );
  </code></pre>
  <p><em>account_setup_service.dart</em></p>
  <pre><code>final accountStreamProvider = StreamProvider.autoDispose((ref) {
    final database = ref.watch(databaseProvider);
    return database != null ? database.accountStream() : const Stream.empty();
  });
  </code></pre>
  <h3>This is the part I'm stuck on. Everything else checks out. How do I consume the <code>accountStreamProvider</code> outside of Flutter in Dart only context? Again, my goal is to simply evaluate whether the stream is empty or if it contains a document.</h3>
  <pre><code>Consumer(builder: (context, watch, _) {
        final accountAsyncValue = watch(accountStreamProvider);
  
        return accountAsyncValue.when(
          // what do I do here to validate that there is an account 
          // info document for the currently authorized user 
          // using the accountStreamProvider?
          // I don't want to return a widget...
          data: (account) =&gt; null,
          loading: () =&gt; null,
          error: (_, __) =&gt; null,
        );
      });
  </code></pre>
  <p>On the RiverPod doc site I've read the &quot;<a href="https://riverpod.dev/docs/concepts/reading#reading-a-provider-outside-of-providers-using-dart-only" rel="nofollow noreferrer">Reading a provider outside of providers using Dart only</a>&quot; reference, however, I'm not sure where to go with it to consume the stream and evaluate data if there is any.</p>