fix a HapticFeedback.vibrate NNBD bug (flutter/engine#25350)
This commit is contained in:
@@ -389,7 +389,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
});
|
||||
return;
|
||||
case 'HapticFeedback.vibrate':
|
||||
final String type = decoded.arguments;
|
||||
final String? type = decoded.arguments;
|
||||
domRenderer.vibrate(_getHapticFeedbackDuration(type));
|
||||
_replyToPlatformMessage(
|
||||
callback, codec.encodeSuccessEnvelope(true));
|
||||
@@ -499,7 +499,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
_replyToPlatformMessage(callback, null);
|
||||
}
|
||||
|
||||
int _getHapticFeedbackDuration(String type) {
|
||||
int _getHapticFeedbackDuration(String? type) {
|
||||
switch (type) {
|
||||
case 'HapticFeedbackType.lightImpact':
|
||||
return DomRenderer.vibrateLightImpact;
|
||||
|
||||
@@ -37,5 +37,24 @@ void testMain() {
|
||||
[true],
|
||||
);
|
||||
});
|
||||
|
||||
test('responds to flutter/platform HapticFeedback.vibrate', () async {
|
||||
const MethodCodec codec = JSONMethodCodec();
|
||||
final Completer<ByteData?> completer = Completer<ByteData?>();
|
||||
ui.PlatformDispatcher.instance.sendPlatformMessage(
|
||||
'flutter/platform',
|
||||
codec.encodeMethodCall(MethodCall(
|
||||
'HapticFeedback.vibrate',
|
||||
)),
|
||||
completer.complete,
|
||||
);
|
||||
|
||||
final ByteData? response = await completer.future;
|
||||
expect(response, isNotNull);
|
||||
expect(
|
||||
codec.decodeEnvelope(response!),
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user