[web] Respond with null for unimplemented method channels (flutter/engine#21423)

This commit is contained in:
Mouad Debbar
2020-09-25 18:49:41 -07:00
committed by GitHub
parent 02ea7e56a3
commit 585f378429
2 changed files with 19 additions and 5 deletions

View File

@@ -679,14 +679,10 @@ class EngineWindow extends ui.Window {
return;
}
// TODO(flutter_web): Some Flutter widgets send platform messages that we
// don't handle on web. So for now, let's just ignore them. In the future,
// we should consider uncommenting the following "callback(null)" line.
// Passing [null] to [callback] indicates that the platform message isn't
// implemented. Look at [MethodChannel.invokeMethod] to see how [null] is
// handled.
// callback(null);
_replyToPlatformMessage(callback, null);
}
int _getHapticFeedbackDuration(String? type) {

View File

@@ -229,6 +229,24 @@ void testMain() {
await completer.future;
});
test('sendPlatformMessage responds even when channel is unknown', () async {
bool responded = false;
final ByteData inputData = ByteData(4);
inputData.setUint32(0, 42);
window.sendPlatformMessage(
'flutter/__unknown__channel__',
null,
(outputData) {
responded = true;
expect(outputData, isNull);
},
);
await Future<void>.delayed(const Duration(milliseconds: 1));
expect(responded, isTrue);
});
test('Window implements locale, locales, and locale change notifications', () async {
// This will count how many times we notified about locale changes.
int localeChangedCount = 0;