From 94fff25d0b14d79994683ce5911b41306fd23761 Mon Sep 17 00:00:00 2001 From: Georg Wechslberger Date: Wed, 11 Sep 2019 18:24:01 +0200 Subject: [PATCH 1/2] added dispose handler for calls to flutter/platform_view --- lib/web_ui/lib/src/engine/platform_views.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/web_ui/lib/src/engine/platform_views.dart b/lib/web_ui/lib/src/engine/platform_views.dart index 56f69258e7585..e22286540f1c4 100644 --- a/lib/web_ui/lib/src/engine/platform_views.dart +++ b/lib/web_ui/lib/src/engine/platform_views.dart @@ -50,6 +50,9 @@ void handlePlatformViewCall( case 'create': _createPlatformView(decoded, callback); return; + case 'dispose': + _disposePlatformView(decoded, callback); + return; } callback(null); } @@ -76,3 +79,15 @@ void _createPlatformView( platformViewRegistry._createdViews[id] = element; callback(codec.encodeSuccessEnvelope(null)); } + +void _disposePlatformView( + MethodCall methodCall, ui.PlatformMessageResponseCallback callback) { + final int id = methodCall.arguments; + const MethodCodec codec = StandardMethodCodec(); + + // remove the root element of the view from the DOM + platformViewRegistry._createdViews[id]?.remove(); + platformViewRegistry._createdViews.remove(id); + + callback(codec.encodeSuccessEnvelope(null)); +} From 07daca6e040db4f022b6a02ef88c836dfdbbc01e Mon Sep 17 00:00:00 2001 From: Georg Wechslberger Date: Thu, 19 Sep 2019 22:32:41 +0200 Subject: [PATCH 2/2] improved comment --- lib/web_ui/lib/src/engine/platform_views.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web_ui/lib/src/engine/platform_views.dart b/lib/web_ui/lib/src/engine/platform_views.dart index e22286540f1c4..33980510f3867 100644 --- a/lib/web_ui/lib/src/engine/platform_views.dart +++ b/lib/web_ui/lib/src/engine/platform_views.dart @@ -85,7 +85,7 @@ void _disposePlatformView( final int id = methodCall.arguments; const MethodCodec codec = StandardMethodCodec(); - // remove the root element of the view from the DOM + // Remove the root element of the view from the DOM. platformViewRegistry._createdViews[id]?.remove(); platformViewRegistry._createdViews.remove(id);