Fix bug where dispose message requires a map (#61035)

This commit is contained in:
Maurice Parrish
2020-07-08 09:57:34 -07:00
committed by GitHub
parent 5f49654734
commit 7d7907e6c1
2 changed files with 14 additions and 6 deletions

View File

@@ -1041,7 +1041,11 @@ class TextureAndroidViewController extends AndroidViewController {
@override
Future<void> _sendDisposeMessage() {
return SystemChannels.platform_views.invokeMethod<void>('dispose', viewId);
return SystemChannels
.platform_views.invokeMethod<void>('dispose', <String, dynamic>{
'id': viewId,
'hybrid': false,
});
}
}

View File

@@ -214,11 +214,15 @@ class FakeAndroidPlatformViewsController {
}
Future<dynamic> _dispose(MethodCall call) {
int id;
if (call.arguments is int) {
id = call.arguments as int;
} else if (call.arguments is Map && call.arguments['hybrid'] == true) {
id = call.arguments['id'] as int;
assert(call.arguments is Map);
final int id = call.arguments['id'] as int;
final bool hybrid = call.arguments['hybrid'] as bool;
if (hybrid && !_views[id].hybrid) {
throw ArgumentError('An $AndroidViewController using hybrid composition must pass `hybrid: true`');
} else if (!hybrid && _views[id].hybrid != null && _views[id].hybrid) {
throw ArgumentError('An $AndroidViewController not using hybrid composition must pass `hybrid: false`');
}
if (!_views.containsKey(id))