title: Empty state page and Navigator issues?
body: <p>I want to implement <a href="https://material.io/design/communication/empty-states.html#content" rel="nofollow noreferrer">empty state page</a> in Flutter app, when news feed is empty.</p>
  
  <p>When there is no activity in feed, I want to show <strong>‘no activity’</strong>. When database has data, I want to load this from <code>StreamBuilder</code> to <code>ListView.builder</code></p>
  
  <p>I try implement with:</p>
  
  <pre><code>child: StreamBuilder(
      stream: collection.snapshots(),
      builder: (context, snapshot) {
  
      if(snapshot.hasData) {
         return ListView.builder(
              itemBuilder: (context, index) =&gt;
                  build(context, snapshot.data.documents[index]),
              itemCount: snapshot.data.documents.length,
           );
        } else {
            return _emptyStateWidget();
        }
  </code></pre>
  
  <p>I must return something in else statement because sometimes snapshot will not have data so will throw error that Widget return null.</p>
  
  <p>But this is causing issues with widget tree. Because if I try to use Navigator.push in <code>build</code> Widget later:</p>
  
  <pre><code>Widget build(BuildContext context, DocumentSnapshot document) {
  …
  FlatButton(
    onPressed: () async {
  
  await function(document);
  
  if(validated == true) {
  await Navigator.push(context, new MaterialPageRoute(
      builder: (BuildContext context) =&gt;
      new Screen(documentInfo: documentInfo)));
  }
  </code></pre>
  
  <p>Error is thrown:</p>
  
  <blockquote>
    <p>Looking up a deactivated widget's ancestor is unsafe. At this point
    the state of the widget's element tree is no longer stable. To safely
    refer to a widget's ancestor in its dispose() method, save a reference
    to the ancestor by calling inheritFromWidgetOfExactType() in the
    widget's didChangeDependencies() method.</p>
  </blockquote>
  
  <p>Is there way to avoid this so that no error is thrown?</p>
  
  <p>For some reason if I call <code>Navigator.push</code> before await <code>function(document)</code> there is no error thrown. But I cannot allow this because it must perform data validation in function before and only navigate if success.</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>After more test I think problem is cause by <code>StreamBuilder</code>. It rebuild whenever it get new event. So this cause issue when call <code>Navigator.push</code> and it get new event so try to rebuild. </p>
  
  <p>How to solve? Is possible to stop <code>StreamBuilder</code> from rebuild descendant?</p>