Skip to content

Instantly share code, notes, and snippets.

View larryaasen's full-sized avatar

Larry Aasen larryaasen

View GitHub Profile
@Boehrsi
Boehrsi / flutter_driver_async_main.dart
Last active March 5, 2023 05:57
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;