[web_ui] add missing dispose handler for MethodCalls to flutter/platform_view (flutter/engine#12226)

* added dispose handler for calls to flutter/platform_view

* improved comment
This commit is contained in:
tauu
2019-09-27 01:48:57 +02:00
committed by Harry Terkelsen
parent 89971abacd
commit b1f058d83d

View File

@@ -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));
}