From c1f6b32c81b00576168e727ac2d0d52290148295 Mon Sep 17 00:00:00 2001 From: Jim Graham Date: Mon, 17 Jul 2023 17:56:25 -0700 Subject: [PATCH] Stabilize hybrid_android_views_integration_test rendering tree (#130751) Fixes: https://github.com/flutter/flutter/issues/130738 A widget was added to explicitly and intentionally overlap the PlatformView so that the rendering tree of Views would always have an underlay and an overlay to match the test expectations. --- .../lib/nested_view_event_page.dart | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart b/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart index bdcb3dd906..b58580c407 100644 --- a/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart +++ b/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart @@ -51,13 +51,30 @@ class NestedViewEventBodyState extends State { children: [ SizedBox( height: 300, - child: showPlatformView ? - AndroidPlatformView( - key: const ValueKey('PlatformView'), - viewType: 'simple_view', - onPlatformViewCreated: onPlatformViewCreated, - useHybridComposition: useHybridComposition, - ) : null, + child: Stack( + alignment: Alignment.topCenter, + children: [ + if (showPlatformView) + AndroidPlatformView( + key: const ValueKey('PlatformView'), + viewType: 'simple_view', + onPlatformViewCreated: onPlatformViewCreated, + useHybridComposition: useHybridComposition, + ), + // The overlapping widget stabilizes the view tree by ensuring + // that there is widget content on top of the platform view. + // Without this widget, we rely on the UI elements down below + // to "incidentally" draw on top of the PlatformView which + // is not a reliable behavior as we eliminate non-visible + // rendering operations throughout the framework and engine. + const Positioned( + top: 50, + child: Text('overlapping widget', + style: TextStyle(color: Colors.yellow), + ), + ), + ], + ), ), if (_lastTestStatus != _LastTestStatus.pending) _statusWidget(), if (viewChannel != null) ... [