@@ -2502,6 +2502,48 @@ void main() {
25022502 },
25032503 );
25042504
2505+ testWidgets (
2506+ 'PlatformViewLink widget should not trigger creation with an empty size' ,
2507+ (WidgetTester tester) async {
2508+ late PlatformViewController controller;
2509+
2510+ final Widget widget = Center (child: SizedBox (
2511+ height: 0 ,
2512+ child: PlatformViewLink (
2513+ viewType: 'webview' ,
2514+ onCreatePlatformView: (PlatformViewCreationParams params) {
2515+ controller = FakeAndroidViewController (params.id, requiresSize: true );
2516+ controller.create ();
2517+ // This test should be simulating one of the texture-based display
2518+ // modes, where `create` is a no-op when not provided a size, and
2519+ // creation is triggered via a later call to setSize, or to `create`
2520+ // with a size.
2521+ expect (controller.awaitingCreation, true );
2522+ return controller;
2523+ },
2524+ surfaceFactory: (BuildContext context, PlatformViewController controller) {
2525+ return PlatformViewSurface (
2526+ gestureRecognizers: const < Factory <OneSequenceGestureRecognizer >> {},
2527+ controller: controller,
2528+ hitTestBehavior: PlatformViewHitTestBehavior .opaque,
2529+ );
2530+ },
2531+ )
2532+ ));
2533+
2534+ await tester.pumpWidget (widget);
2535+
2536+ expect (
2537+ tester.allWidgets.map ((Widget widget) => widget.runtimeType.toString ()).toList (),
2538+ equals (< String > ['Center' , 'SizedBox' , 'PlatformViewLink' , '_PlatformViewPlaceHolder' ]),
2539+ );
2540+
2541+ // 'create' should not have been called by PlatformViewLink, since its
2542+ // size is empty.
2543+ expect (controller.awaitingCreation, true );
2544+ },
2545+ );
2546+
25052547 testWidgets (
25062548 'PlatformViewLink calls create when needed for Android texture display modes' ,
25072549 (WidgetTester tester) async {
@@ -2541,6 +2583,9 @@ void main() {
25412583 equals (< String > ['PlatformViewLink' , '_PlatformViewPlaceHolder' ]),
25422584 );
25432585
2586+ // Layout should have triggered a create call. Simulate the callback
2587+ // that the real controller would make after creation.
2588+ expect (controller.awaitingCreation, false );
25442589 onPlatformViewCreatedCallBack (createdPlatformViewId);
25452590
25462591 await tester.pump ();
@@ -2551,7 +2596,6 @@ void main() {
25512596 );
25522597
25532598 expect (createdPlatformViewId, currentViewId + 1 );
2554- expect (controller.awaitingCreation, false );
25552599 },
25562600 );
25572601
0 commit comments