From 09f6515b73325bca745b85a8c5b016ec9c204d3f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 16 Aug 2019 14:24:01 -0700 Subject: [PATCH] PlatformViewLink: Rename CreatePlatformViewController to CreatePlatformViewCallback (#38710) --- .../lib/src/widgets/platform_view.dart | 22 +++++++++---------- .../test/widgets/platform_view_test.dart | 8 +++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/flutter/lib/src/widgets/platform_view.dart b/packages/flutter/lib/src/widgets/platform_view.dart index 17c4c22257..df101da286 100644 --- a/packages/flutter/lib/src/widgets/platform_view.dart +++ b/packages/flutter/lib/src/widgets/platform_view.dart @@ -583,7 +583,7 @@ class _UiKitPlatformView extends LeafRenderObjectWidget { /// The parameters used to create a [PlatformViewController]. /// -/// See also [CreatePlatformViewController] which uses this object to create a [PlatformViewController]. +/// See also [CreatePlatformViewCallback] which uses this object to create a [PlatformViewController]. class PlatformViewCreationParams { const PlatformViewCreationParams._({ @@ -615,7 +615,7 @@ typedef PlatformViewSurfaceFactory = Widget Function(BuildContext context, Platf /// params [PlatformViewCreationParams.id] field. /// /// See also [PlatformViewLink.onCreate]. -typedef CreatePlatformViewController = PlatformViewController Function(PlatformViewCreationParams params); +typedef CreatePlatformViewCallback = PlatformViewController Function(PlatformViewCreationParams params); /// Links a platform view with the Flutter framework. /// @@ -631,7 +631,7 @@ typedef CreatePlatformViewController = PlatformViewController Function(PlatformV /// @override /// Widget build(BuildContext context) { /// return PlatformViewLink( -/// createCallback: createFooWebView, +/// onCreatePlatformView: createFooWebView, /// surfaceFactory: (BuildContext context, PlatformViewController controller) { /// return PlatformViewSurface( /// gestureRecognizers: gestureRecognizers, @@ -644,13 +644,13 @@ typedef CreatePlatformViewController = PlatformViewController Function(PlatformV /// } /// ``` /// -/// The `surfaceFactory` and the `createPlatformViewController` only take affect when the state of this widget is initialized. -/// If the widget is rebuilt without losing its state, `surfaceFactory` and `createPlatformViewController` are ignored. +/// The `surfaceFactory` and the `onCreatePlatformView` only take affect when the state of this widget is initialized. +/// If the widget is rebuilt without losing its state, `surfaceFactory` and `onCreatePlatformView` are ignored. class PlatformViewLink extends StatefulWidget { /// Construct a [PlatformViewLink] widget. /// - /// The `surfaceFactory` and the `createPlatformViewController` must not be null. + /// The `surfaceFactory` and the `onCreatePlatformView` must not be null. /// /// See also: /// * [PlatformViewSurface] for details on the widget returned by `surfaceFactory`. @@ -658,16 +658,16 @@ class PlatformViewLink extends StatefulWidget { const PlatformViewLink({ Key key, @required PlatformViewSurfaceFactory surfaceFactory, - @required CreatePlatformViewController createPlatformViewController, + @required CreatePlatformViewCallback onCreatePlatformView, }) : assert(surfaceFactory != null), - assert(createPlatformViewController != null), + assert(onCreatePlatformView != null), _surfaceFactory = surfaceFactory, - _createPlatformViewController = createPlatformViewController, + _onCreatePlatformView = onCreatePlatformView, super(key: key); final PlatformViewSurfaceFactory _surfaceFactory; - final CreatePlatformViewController _createPlatformViewController; + final CreatePlatformViewCallback _onCreatePlatformView; @override State createState() => _PlatformViewLinkState(); @@ -697,7 +697,7 @@ class _PlatformViewLinkState extends State { void _initialize() { _id = platformViewsRegistry.getNextPlatformViewId(); - _controller = widget._createPlatformViewController(PlatformViewCreationParams._(id:_id, onPlatformViewCreated:_onPlatformViewCreated)); + _controller = widget._onCreatePlatformView(PlatformViewCreationParams._(id:_id, onPlatformViewCreated:_onPlatformViewCreated)); } void _onPlatformViewCreated(int id) { diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 008a960402..db3920f83a 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -1939,7 +1939,7 @@ void main() { PlatformViewCreatedCallback onPlatformViewCreatedCallBack; - final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ + final PlatformViewLink platformViewLink = PlatformViewLink(onCreatePlatformView: (PlatformViewCreationParams params){ onPlatformViewCreatedCallBack = params.onPlatformViewCreated; createdPlatformViewId = params.id; return FakePlatformViewController(params.id); @@ -1967,7 +1967,7 @@ void main() { testWidgets('PlatformViewLink Widget dispose', (WidgetTester tester) async { FakePlatformViewController disposedController; - final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ + final PlatformViewLink platformViewLink = PlatformViewLink(onCreatePlatformView: (PlatformViewCreationParams params){ disposedController = FakePlatformViewController(params.id); params.onPlatformViewCreated(params.id); return disposedController; @@ -1996,7 +1996,7 @@ void main() { PlatformViewLink createPlatformViewLink() { return PlatformViewLink( key: key, - createPlatformViewController: (PlatformViewCreationParams params){ + onCreatePlatformView: (PlatformViewCreationParams params){ ids.add(params.id); controller = FakePlatformViewController(params.id); params.onPlatformViewCreated(params.id); @@ -2042,7 +2042,7 @@ void main() { }); testWidgets('PlatformViewLink can take any widget to return in the SurfaceFactory', (WidgetTester tester) async { - final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ + final PlatformViewLink platformViewLink = PlatformViewLink(onCreatePlatformView: (PlatformViewCreationParams params){ params.onPlatformViewCreated(params.id); return FakePlatformViewController(params.id); }, surfaceFactory: (BuildContext context,PlatformViewController controller) {