-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
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 new Image.asset('myasset.png', key: const Key('a')). The test code looks like this:
test('Widget with Image', () async {
await driver.waitFor(find.byValueKey('a'));
await driver.waitUntilNoTransientCallbacks();
await scuba.diffScreenshot('opportunities');
});
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 (<5% of the time), the test will take a screenshot where the image is loaded and visible.
If I add await new Future.delayed(const Duration(seconds: 1));, then the Image is always loaded, but this is likely wasting some amount of time and/or prone to flaking. I think that waitUntilNoTransientCallbacks 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?
Thanks!