Skip to content

Commit

Permalink
[web_ui] add missing dispose handler for MethodCalls to flutter/platf…
Browse files Browse the repository at this point in the history
…orm_view (#12226)

* added dispose handler for calls to flutter/platform_view

* improved comment
  • Loading branch information
tauu authored and Harry Terkelsen committed Sep 26, 2019
1 parent 92d020f commit 84c167d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/web_ui/lib/src/engine/platform_views.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ void handlePlatformViewCall(
case 'create':
_createPlatformView(decoded, callback);
return;
case 'dispose':
_disposePlatformView(decoded, callback);
return;
}
callback(null);
}
Expand All @@ -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));
}

0 comments on commit 84c167d

Please sign in to comment.