Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akovardin/e24924e7fb3042c38cceef133cfead09 to your computer and use it in GitHub Desktop.
Save akovardin/e24924e7fb3042c38cceef133cfead09 to your computer and use it in GitHub Desktop.
During development I encountered https://github.com/flutter/flutter/issues/41029 and didn't liked the solution with hardcoded waiting times. I'm now waiting for the first frame to be rastered successfully and ignoring errors in the meantime. This works well for my tests and avoids hardcoded timings, which often fail (e.g. on a different machine).
Future<FlutterDriver> setupAndGetDriver() async {
FlutterDriver driver = await FlutterDriver.connect();
var connected = false;
while (!connected) {
try {
await driver.waitUntilFirstFrameRasterized();
connected = true;
} catch (error) {}
}
return driver;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment