@@ -2502,6 +2502,48 @@ void main() {
2502
2502
},
2503
2503
);
2504
2504
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
+
2505
2547
testWidgets (
2506
2548
'PlatformViewLink calls create when needed for Android texture display modes' ,
2507
2549
(WidgetTester tester) async {
@@ -2541,6 +2583,9 @@ void main() {
2541
2583
equals (< String > ['PlatformViewLink' , '_PlatformViewPlaceHolder' ]),
2542
2584
);
2543
2585
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 );
2544
2589
onPlatformViewCreatedCallBack (createdPlatformViewId);
2545
2590
2546
2591
await tester.pump ();
@@ -2551,7 +2596,6 @@ void main() {
2551
2596
);
2552
2597
2553
2598
expect (createdPlatformViewId, currentViewId + 1 );
2554
- expect (controller.awaitingCreation, false );
2555
2599
},
2556
2600
);
2557
2601
0 commit comments