prepareHostNavigationMatchCapture function
Waits until a hosted navigation match has survived a paint opportunity. Route notifications can precede the destination's first rendered frame; returning false leaves the normal step-finished capture eligible.
Implementation
Future<bool> prepareHostNavigationMatchCapture({
required WidgetTester tester,
required String? screen,
}) async {
if (screen == null || screen.isEmpty) return false;
final tracker = ScreenTracker();
bool targetIsVisible() =>
tracker.isScreenVisible(screenName: screen) ||
tracker.isScreenVisible(screenId: screen);
if (!targetIsVisible()) return false;
await pumpScreenshotStabilityFrames(tester);
if (!targetIsVisible()) return false;
if (areVisibleLottiesReady(tester)) {
seekVisibleLottiesForScreenshot(tester);
await tester.pump();
}
return targetIsVisible();
}