Unverified Commit 09f6515b authored by Chris Yang's avatar Chris Yang Committed by GitHub

PlatformViewLink: Rename CreatePlatformViewController to CreatePlatformViewCallback (#38710)

parent cac8fa5d
...@@ -583,7 +583,7 @@ class _UiKitPlatformView extends LeafRenderObjectWidget { ...@@ -583,7 +583,7 @@ class _UiKitPlatformView extends LeafRenderObjectWidget {
/// The parameters used to create a [PlatformViewController]. /// 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 { class PlatformViewCreationParams {
const PlatformViewCreationParams._({ const PlatformViewCreationParams._({
...@@ -615,7 +615,7 @@ typedef PlatformViewSurfaceFactory = Widget Function(BuildContext context, Platf ...@@ -615,7 +615,7 @@ typedef PlatformViewSurfaceFactory = Widget Function(BuildContext context, Platf
/// params [PlatformViewCreationParams.id] field. /// params [PlatformViewCreationParams.id] field.
/// ///
/// See also [PlatformViewLink.onCreate]. /// See also [PlatformViewLink.onCreate].
typedef CreatePlatformViewController = PlatformViewController Function(PlatformViewCreationParams params); typedef CreatePlatformViewCallback = PlatformViewController Function(PlatformViewCreationParams params);
/// Links a platform view with the Flutter framework. /// Links a platform view with the Flutter framework.
/// ///
...@@ -631,7 +631,7 @@ typedef CreatePlatformViewController = PlatformViewController Function(PlatformV ...@@ -631,7 +631,7 @@ typedef CreatePlatformViewController = PlatformViewController Function(PlatformV
/// @override /// @override
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return PlatformViewLink( /// return PlatformViewLink(
/// createCallback: createFooWebView, /// onCreatePlatformView: createFooWebView,
/// surfaceFactory: (BuildContext context, PlatformViewController controller) { /// surfaceFactory: (BuildContext context, PlatformViewController controller) {
/// return PlatformViewSurface( /// return PlatformViewSurface(
/// gestureRecognizers: gestureRecognizers, /// gestureRecognizers: gestureRecognizers,
...@@ -644,13 +644,13 @@ typedef CreatePlatformViewController = PlatformViewController Function(PlatformV ...@@ -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. /// 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 `createPlatformViewController` are ignored. /// If the widget is rebuilt without losing its state, `surfaceFactory` and `onCreatePlatformView` are ignored.
class PlatformViewLink extends StatefulWidget { class PlatformViewLink extends StatefulWidget {
/// Construct a [PlatformViewLink] widget. /// Construct a [PlatformViewLink] widget.
/// ///
/// The `surfaceFactory` and the `createPlatformViewController` must not be null. /// The `surfaceFactory` and the `onCreatePlatformView` must not be null.
/// ///
/// See also: /// See also:
/// * [PlatformViewSurface] for details on the widget returned by `surfaceFactory`. /// * [PlatformViewSurface] for details on the widget returned by `surfaceFactory`.
...@@ -658,16 +658,16 @@ class PlatformViewLink extends StatefulWidget { ...@@ -658,16 +658,16 @@ class PlatformViewLink extends StatefulWidget {
const PlatformViewLink({ const PlatformViewLink({
Key key, Key key,
@required PlatformViewSurfaceFactory surfaceFactory, @required PlatformViewSurfaceFactory surfaceFactory,
@required CreatePlatformViewController createPlatformViewController, @required CreatePlatformViewCallback onCreatePlatformView,
}) : assert(surfaceFactory != null), }) : assert(surfaceFactory != null),
assert(createPlatformViewController != null), assert(onCreatePlatformView != null),
_surfaceFactory = surfaceFactory, _surfaceFactory = surfaceFactory,
_createPlatformViewController = createPlatformViewController, _onCreatePlatformView = onCreatePlatformView,
super(key: key); super(key: key);
final PlatformViewSurfaceFactory _surfaceFactory; final PlatformViewSurfaceFactory _surfaceFactory;
final CreatePlatformViewController _createPlatformViewController; final CreatePlatformViewCallback _onCreatePlatformView;
@override @override
State<StatefulWidget> createState() => _PlatformViewLinkState(); State<StatefulWidget> createState() => _PlatformViewLinkState();
...@@ -697,7 +697,7 @@ class _PlatformViewLinkState extends State<PlatformViewLink> { ...@@ -697,7 +697,7 @@ class _PlatformViewLinkState extends State<PlatformViewLink> {
void _initialize() { void _initialize() {
_id = platformViewsRegistry.getNextPlatformViewId(); _id = platformViewsRegistry.getNextPlatformViewId();
_controller = widget._createPlatformViewController(PlatformViewCreationParams._(id:_id, onPlatformViewCreated:_onPlatformViewCreated)); _controller = widget._onCreatePlatformView(PlatformViewCreationParams._(id:_id, onPlatformViewCreated:_onPlatformViewCreated));
} }
void _onPlatformViewCreated(int id) { void _onPlatformViewCreated(int id) {
......
...@@ -1939,7 +1939,7 @@ void main() { ...@@ -1939,7 +1939,7 @@ void main() {
PlatformViewCreatedCallback onPlatformViewCreatedCallBack; PlatformViewCreatedCallback onPlatformViewCreatedCallBack;
final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ final PlatformViewLink platformViewLink = PlatformViewLink(onCreatePlatformView: (PlatformViewCreationParams params){
onPlatformViewCreatedCallBack = params.onPlatformViewCreated; onPlatformViewCreatedCallBack = params.onPlatformViewCreated;
createdPlatformViewId = params.id; createdPlatformViewId = params.id;
return FakePlatformViewController(params.id); return FakePlatformViewController(params.id);
...@@ -1967,7 +1967,7 @@ void main() { ...@@ -1967,7 +1967,7 @@ void main() {
testWidgets('PlatformViewLink Widget dispose', (WidgetTester tester) async { testWidgets('PlatformViewLink Widget dispose', (WidgetTester tester) async {
FakePlatformViewController disposedController; FakePlatformViewController disposedController;
final PlatformViewLink platformViewLink = PlatformViewLink(createPlatformViewController: (PlatformViewCreationParams params){ final PlatformViewLink platformViewLink = PlatformViewLink(onCreatePlatformView: (PlatformViewCreationParams params){
disposedController = FakePlatformViewController(params.id); disposedController = FakePlatformViewController(params.id);
params.onPlatformViewCreated(params.id); params.onPlatformViewCreated(params.id);
return disposedController; return disposedController;
...@@ -1996,7 +1996,7 @@ void main() { ...@@ -1996,7 +1996,7 @@ void main() {
PlatformViewLink createPlatformViewLink() { PlatformViewLink createPlatformViewLink() {
return PlatformViewLink( return PlatformViewLink(
key: key, key: key,
createPlatformViewController: (PlatformViewCreationParams params){ onCreatePlatformView: (PlatformViewCreationParams params){
ids.add(params.id); ids.add(params.id);
controller = FakePlatformViewController(params.id); controller = FakePlatformViewController(params.id);
params.onPlatformViewCreated(params.id); params.onPlatformViewCreated(params.id);
...@@ -2042,7 +2042,7 @@ void main() { ...@@ -2042,7 +2042,7 @@ void main() {
}); });
testWidgets('PlatformViewLink can take any widget to return in the SurfaceFactory', (WidgetTester tester) async { 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); params.onPlatformViewCreated(params.id);
return FakePlatformViewController(params.id); return FakePlatformViewController(params.id);
}, surfaceFactory: (BuildContext context,PlatformViewController controller) { }, surfaceFactory: (BuildContext context,PlatformViewController controller) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment