diff --git a/lib/web_ui/lib/src/engine/platform_views.dart b/lib/web_ui/lib/src/engine/platform_views.dart index 56f69258e7585..33980510f3867 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)); +}