<p dir="auto">Consider a widget that conditionally depends on an InheritedModel aspect:</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="if (foo) {
  return Text(&quot;Foo&quot;, MyModel.of(context, aspect: MyAspect));
}"><pre class="notranslate"><span class="pl-k">if</span> (foo) {
  <span class="pl-k">return</span> <span class="pl-c1">Text</span>(<span class="pl-s">"Foo"</span>, <span class="pl-c1">MyModel</span>.<span class="pl-en">of</span>(context, aspect<span class="pl-k">:</span> <span class="pl-c1">MyAspect</span>));
}</pre></div>
<p dir="auto">It seems that if <code class="notranslate">foo</code> requirement is met once. Then even if that condition fails in the future; the widget will stay dependent on the MyModel.</p>
<p dir="auto">This leads to unnecessary builds.  I'd expect the list of dependencies to be cleared before <code class="notranslate">build</code> call</p>
<p dir="auto">Suppose widget <code class="notranslate">W</code> depends on <code class="notranslate">InheritedWidget</code> <code class="notranslate">D</code> based some <code class="notranslate">condition</code> be true. After a asynchronous operation, <code class="notranslate">condition</code> changed from <code class="notranslate">true</code> to <code class="notranslate">false</code>. From now on, <code class="notranslate">W</code> doesn't depend on <code class="notranslate">D</code> actually, but <code class="notranslate">W</code> still got rebuilt due to changes in <code class="notranslate">D</code>. <code class="notranslate">condition</code> can be internal state of <code class="notranslate">W</code> or information from other <code class="notranslate">InheritedWidget</code>.</p>
<p dir="auto">I post a test <a href="https://gist.github.com/kezhuw/3ff4cf46d2d60565960caf2257cd1242">gist</a> to show this.</p>