<p dir="auto">I have a screenshot test using flutter_driver where I'm taking a screenshot of a Widget which contains an Image widget which is created via <code class="notranslate">new Image.asset('myasset.png', key: const Key('a'))</code>. The test code looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test('Widget with Image', () async {
      await driver.waitFor(find.byValueKey('a'));
      await driver.waitUntilNoTransientCallbacks();
      await scuba.diffScreenshot('opportunities');
    });"><pre class="notranslate"><code class="notranslate">test('Widget with Image', () async {
      await driver.waitFor(find.byValueKey('a'));
      await driver.waitUntilNoTransientCallbacks();
      await scuba.diffScreenshot('opportunities');
    });
</code></pre></div>
<p dir="auto">This takes a screenshot where the Image is in the tree (I can tell because it changes the alignment of the other elements in the Widget), but has not yet been loaded (it's blank). Very occasionally (&lt;5% of the time), the test will take a screenshot where the image is loaded and visible.</p>
<p dir="auto">If I add <code class="notranslate">await new Future.delayed(const Duration(seconds: 1));</code>, then the Image is always loaded, but this is likely wasting some amount of time and/or prone to flaking. I think that <code class="notranslate">waitUntilNoTransientCallbacks</code> is probably supposed to be await'ing whatever asset loading is happening in the background; if not, could we expose some other hook that would enable this?</p>
<p dir="auto">Thanks!</p>
<p dir="auto">Collecting a screenshot with <code class="notranslate">driver.screenshot()</code> after calling <code class="notranslate">driver.waitUntilNoTransientCallbacks()</code>  doesn't guarantee that the current frame's display list will have reached the GPU before the screenshot is taken.</p>