From 0b087a898ae787b86b9e1fc9d275dc0300da3780 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 16 Aug 2019 11:23:21 -0700 Subject: [PATCH] PlatformViewLink: update cached surface to be Widget type (#38639) --- .../flutter/lib/src/widgets/platform_view.dart | 2 +- .../test/widgets/platform_view_test.dart | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/widgets/platform_view.dart b/packages/flutter/lib/src/widgets/platform_view.dart index 33cc5193f1..17c4c22257 100644 --- a/packages/flutter/lib/src/widgets/platform_view.dart +++ b/packages/flutter/lib/src/widgets/platform_view.dart @@ -678,7 +678,7 @@ class _PlatformViewLinkState extends State { int _id; PlatformViewController _controller; bool _platformViewCreated = false; - PlatformViewSurface _surface; + Widget _surface; @override Widget build(BuildContext context) { diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 9ee156082e..008a960402 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -1968,7 +1968,6 @@ void main() { testWidgets('PlatformViewLink Widget dispose', (WidgetTester tester) async { FakePlatformViewController disposedController; final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ - params.onPlatformViewCreated(params.id); disposedController = FakePlatformViewController(params.id); params.onPlatformViewCreated(params.id); return disposedController; @@ -2041,5 +2040,21 @@ void main() { ]), ); }); + + testWidgets('PlatformViewLink can take any widget to return in the SurfaceFactory', (WidgetTester tester) async { + final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ + params.onPlatformViewCreated(params.id); + return FakePlatformViewController(params.id); + }, surfaceFactory: (BuildContext context,PlatformViewController controller) { + return Container(); + }); + + await tester.pumpWidget(platformViewLink); + + final Container container = tester.allWidgets.firstWhere((Widget widget){ + return widget is Container; + }); + expect(container, isNotNull); + }); }); }