Unverified Commit 5a862ebe authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Replace dynamic with Object? in SystemChannels (#94629)

parent ec40357f
...@@ -284,7 +284,7 @@ abstract class RawKeyEvent with Diagnosticable { ...@@ -284,7 +284,7 @@ abstract class RawKeyEvent with Diagnosticable {
/// Creates a concrete [RawKeyEvent] class from a message in the form received /// Creates a concrete [RawKeyEvent] class from a message in the form received
/// on the [SystemChannels.keyEvent] channel. /// on the [SystemChannels.keyEvent] channel.
factory RawKeyEvent.fromMessage(Map<String, dynamic> message) { factory RawKeyEvent.fromMessage(Map<String, Object?> message) {
String? character; String? character;
RawKeyEventData _dataFromWeb() { RawKeyEventData _dataFromWeb() {
final String? key = message['key'] as String?; final String? key = message['key'] as String?;
...@@ -303,7 +303,7 @@ abstract class RawKeyEvent with Diagnosticable { ...@@ -303,7 +303,7 @@ abstract class RawKeyEvent with Diagnosticable {
if (kIsWeb) { if (kIsWeb) {
data = _dataFromWeb(); data = _dataFromWeb();
} else { } else {
final String keymap = message['keymap'] as String; final String keymap = message['keymap']! as String;
switch (keymap) { switch (keymap) {
case 'android': case 'android':
data = RawKeyEventDataAndroid( data = RawKeyEventDataAndroid(
...@@ -388,7 +388,7 @@ abstract class RawKeyEvent with Diagnosticable { ...@@ -388,7 +388,7 @@ abstract class RawKeyEvent with Diagnosticable {
throw FlutterError('Unknown keymap for key events: $keymap'); throw FlutterError('Unknown keymap for key events: $keymap');
} }
} }
final String type = message['type'] as String; final String type = message['type']! as String;
switch (type) { switch (type) {
case 'keydown': case 'keydown':
return RawKeyDownEvent(data: data, character: character); return RawKeyDownEvent(data: data, character: character);
......
...@@ -240,7 +240,7 @@ class SystemChannels { ...@@ -240,7 +240,7 @@ class SystemChannels {
/// * [RawKeyboard], which uses this channel to expose key data. /// * [RawKeyboard], which uses this channel to expose key data.
/// * [new RawKeyEvent.fromMessage], which can decode this data into the [RawKeyEvent] /// * [new RawKeyEvent.fromMessage], which can decode this data into the [RawKeyEvent]
/// subclasses mentioned above. /// subclasses mentioned above.
static const BasicMessageChannel<dynamic> keyEvent = BasicMessageChannel<dynamic>( static const BasicMessageChannel<Object?> keyEvent = BasicMessageChannel<Object?>(
'flutter/keyevent', 'flutter/keyevent',
JSONMessageCodec(), JSONMessageCodec(),
); );
...@@ -271,7 +271,7 @@ class SystemChannels { ...@@ -271,7 +271,7 @@ class SystemChannels {
/// applications to release caches to free up more memory. See /// applications to release caches to free up more memory. See
/// [WidgetsBindingObserver.didHaveMemoryPressure], which triggers whenever /// [WidgetsBindingObserver.didHaveMemoryPressure], which triggers whenever
/// a message is received on this channel. /// a message is received on this channel.
static const BasicMessageChannel<dynamic> system = BasicMessageChannel<dynamic>( static const BasicMessageChannel<Object?> system = BasicMessageChannel<Object?>(
'flutter/system', 'flutter/system',
JSONMessageCodec(), JSONMessageCodec(),
); );
...@@ -283,7 +283,7 @@ class SystemChannels { ...@@ -283,7 +283,7 @@ class SystemChannels {
/// * [SemanticsEvent] and its subclasses for a list of valid accessibility /// * [SemanticsEvent] and its subclasses for a list of valid accessibility
/// events that can be sent over this channel. /// events that can be sent over this channel.
/// * [SemanticsNode.sendEvent], which uses this channel to dispatch events. /// * [SemanticsNode.sendEvent], which uses this channel to dispatch events.
static const BasicMessageChannel<dynamic> accessibility = BasicMessageChannel<dynamic>( static const BasicMessageChannel<Object?> accessibility = BasicMessageChannel<Object?>(
'flutter/accessibility', 'flutter/accessibility',
StandardMessageCodec(), StandardMessageCodec(),
); );
...@@ -311,7 +311,7 @@ class SystemChannels { ...@@ -311,7 +311,7 @@ class SystemChannels {
/// A [MethodChannel] for configuring mouse cursors. /// A [MethodChannel] for configuring mouse cursors.
/// ///
/// All outgoing methods defined for this channel uses a `Map<String, dynamic>` /// All outgoing methods defined for this channel uses a `Map<String, Object?>`
/// to contain multiple parameters, including the following methods (invoked /// to contain multiple parameters, including the following methods (invoked
/// using [OptionalMethodChannel.invokeMethod]): /// using [OptionalMethodChannel.invokeMethod]):
/// ///
......
...@@ -1086,15 +1086,15 @@ void main() { ...@@ -1086,15 +1086,15 @@ void main() {
LogicalKeyboardKey.keyA, LogicalKeyboardKey.keyA,
platform: 'android', platform: 'android',
); );
Map<String, dynamic>? message; Map<String, Object?>? message;
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.keyEvent.name, SystemChannels.keyEvent.name,
SystemChannels.keyEvent.codec.encodeMessage(data), SystemChannels.keyEvent.codec.encodeMessage(data),
(ByteData? data) { (ByteData? data) {
message = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, dynamic>; message = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, Object?>?;
}, },
); );
expect(message, equals(<String, dynamic>{ 'handled': false })); expect(message, equals(<String, Object?>{ 'handled': false }));
message = null; message = null;
// Set up a widget that will receive focused text events. // Set up a widget that will receive focused text events.
...@@ -1115,15 +1115,15 @@ void main() { ...@@ -1115,15 +1115,15 @@ void main() {
SystemChannels.keyEvent.name, SystemChannels.keyEvent.name,
SystemChannels.keyEvent.codec.encodeMessage(data), SystemChannels.keyEvent.codec.encodeMessage(data),
(ByteData? data) { (ByteData? data) {
message = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, dynamic>; message = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, Object?>?;
}, },
); );
expect(message, equals(<String, dynamic>{ 'handled': true })); expect(message, equals(<String, Object?>{ 'handled': true }));
tester.binding.defaultBinaryMessenger.setMockMessageHandler(SystemChannels.keyEvent.name, null); tester.binding.defaultBinaryMessenger.setMockMessageHandler(SystemChannels.keyEvent.name, null);
}); });
test('data.toString', () { test('data.toString', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'android', 'keymap': 'android',
'keyCode': 29, 'keyCode': 29,
...@@ -1141,7 +1141,7 @@ void main() { ...@@ -1141,7 +1141,7 @@ void main() {
}); });
test('data.equality', () { test('data.equality', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'android', 'keymap': 'android',
'keyCode': 29, 'keyCode': 29,
...@@ -1833,7 +1833,7 @@ void main() { ...@@ -1833,7 +1833,7 @@ void main() {
}); });
test('Unprintable keyboard keys are correctly translated', () { test('Unprintable keyboard keys are correctly translated', () {
final RawKeyEvent leftArrowKey = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent leftArrowKey = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'windows', 'keymap': 'windows',
'keyCode': 37, // keyCode for left arrow. 'keyCode': 37, // keyCode for left arrow.
...@@ -1854,7 +1854,7 @@ void main() { ...@@ -1854,7 +1854,7 @@ void main() {
Future<void> simulateKeyEventMessage(String type, int keyCode, int scanCode) { Future<void> simulateKeyEventMessage(String type, int keyCode, int scanCode) {
return ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( return ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.keyEvent.name, SystemChannels.keyEvent.name,
SystemChannels.keyEvent.codec.encodeMessage(<String, dynamic>{ SystemChannels.keyEvent.codec.encodeMessage(<String, Object?>{
'type': type, 'type': type,
'keymap': platform, 'keymap': platform,
'keyCode': keyCode, 'keyCode': keyCode,
...@@ -1862,8 +1862,8 @@ void main() { ...@@ -1862,8 +1862,8 @@ void main() {
'modifiers': 0, 'modifiers': 0,
}), }),
(ByteData? data) { (ByteData? data) {
final Map<String, dynamic> decoded = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, dynamic>; final Map<String, Object?> decoded = SystemChannels.keyEvent.codec.decodeMessage(data)! as Map<String, Object?>;
lastHandled = decoded['handled'] as bool; lastHandled = decoded['handled']! as bool;
}, },
); );
} }
...@@ -1879,7 +1879,7 @@ void main() { ...@@ -1879,7 +1879,7 @@ void main() {
}); });
test('data.toString', () { test('data.toString', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'windows', 'keymap': 'windows',
'keyCode': 0x00000010, 'keyCode': 0x00000010,
...@@ -1891,7 +1891,7 @@ void main() { ...@@ -1891,7 +1891,7 @@ void main() {
}); });
test('data.equality', () { test('data.equality', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'windows', 'keymap': 'windows',
'keyCode': 0x00000010, 'keyCode': 0x00000010,
...@@ -1905,7 +1905,7 @@ void main() { ...@@ -1905,7 +1905,7 @@ void main() {
characterCodePoint: 10, characterCodePoint: 10,
)); ));
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'windows', 'keymap': 'windows',
'keyCode': 0x00000010, 'keyCode': 0x00000010,
...@@ -1950,7 +1950,7 @@ void main() { ...@@ -1950,7 +1950,7 @@ void main() {
for (final int modifier in modifierTests.keys) { for (final int modifier in modifierTests.keys) {
for (final bool isDown in <bool>[true, false]) { for (final bool isDown in <bool>[true, false]) {
for (final bool isLeft in <bool>[true, false]) { for (final bool isLeft in <bool>[true, false]) {
final RawKeyEvent event = RawKeyEvent.fromMessage(<String, dynamic>{ final RawKeyEvent event = RawKeyEvent.fromMessage(<String, Object?>{
'type': isDown ? 'keydown' : 'keyup', 'type': isDown ? 'keydown' : 'keyup',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -1988,7 +1988,7 @@ void main() { ...@@ -1988,7 +1988,7 @@ void main() {
// No need to combine CTRL key with itself. // No need to combine CTRL key with itself.
continue; continue;
} }
final RawKeyEvent event = RawKeyEvent.fromMessage(<String, dynamic>{ final RawKeyEvent event = RawKeyEvent.fromMessage(<String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2024,7 +2024,7 @@ void main() { ...@@ -2024,7 +2024,7 @@ void main() {
}); });
test('Printable keyboard keys are correctly translated', () { test('Printable keyboard keys are correctly translated', () {
final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2040,7 +2040,7 @@ void main() { ...@@ -2040,7 +2040,7 @@ void main() {
}); });
test('Code points with two Unicode scalar values are allowed', () { test('Code points with two Unicode scalar values are allowed', () {
final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2058,7 +2058,7 @@ void main() { ...@@ -2058,7 +2058,7 @@ void main() {
test('Code points with more than three Unicode scalar values are not allowed', () { test('Code points with more than three Unicode scalar values are not allowed', () {
// |keyCode| and |scanCode| are arbitrary values. This test should fail due to an invalid |unicodeScalarValues|. // |keyCode| and |scanCode| are arbitrary values. This test should fail due to an invalid |unicodeScalarValues|.
void _createFailingKey() { void _createFailingKey() {
RawKeyEvent.fromMessage(const <String, dynamic>{ RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2073,7 +2073,7 @@ void main() { ...@@ -2073,7 +2073,7 @@ void main() {
}); });
test('Control keyboard keys are correctly translated', () { test('Control keyboard keys are correctly translated', () {
final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2089,7 +2089,7 @@ void main() { ...@@ -2089,7 +2089,7 @@ void main() {
}); });
test('Modifier keyboard keys are correctly translated', () { test('Modifier keyboard keys are correctly translated', () {
final RawKeyEvent shiftLeftKeyEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent shiftLeftKeyEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2104,7 +2104,7 @@ void main() { ...@@ -2104,7 +2104,7 @@ void main() {
}); });
test('data.toString', () { test('data.toString', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2117,7 +2117,7 @@ void main() { ...@@ -2117,7 +2117,7 @@ void main() {
}); });
test('data.equality', () { test('data.equality', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2134,7 +2134,7 @@ void main() { ...@@ -2134,7 +2134,7 @@ void main() {
isDown: true, isDown: true,
)); ));
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'glfw', 'toolkit': 'glfw',
...@@ -2182,7 +2182,7 @@ void main() { ...@@ -2182,7 +2182,7 @@ void main() {
for (final int modifier in modifierTests.keys) { for (final int modifier in modifierTests.keys) {
for (final bool isDown in <bool>[true, false]) { for (final bool isDown in <bool>[true, false]) {
for (final bool isLeft in <bool>[true, false]) { for (final bool isLeft in <bool>[true, false]) {
final RawKeyEvent event = RawKeyEvent.fromMessage(<String, dynamic>{ final RawKeyEvent event = RawKeyEvent.fromMessage(<String, Object?>{
'type': isDown ? 'keydown' : 'keyup', 'type': isDown ? 'keydown' : 'keyup',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2220,7 +2220,7 @@ void main() { ...@@ -2220,7 +2220,7 @@ void main() {
// No need to combine CTRL key with itself. // No need to combine CTRL key with itself.
continue; continue;
} }
final RawKeyEvent event = RawKeyEvent.fromMessage(<String, dynamic>{ final RawKeyEvent event = RawKeyEvent.fromMessage(<String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2256,7 +2256,7 @@ void main() { ...@@ -2256,7 +2256,7 @@ void main() {
}); });
test('Printable keyboard keys are correctly translated', () { test('Printable keyboard keys are correctly translated', () {
final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2272,7 +2272,7 @@ void main() { ...@@ -2272,7 +2272,7 @@ void main() {
}); });
test('Code points with two Unicode scalar values are allowed', () { test('Code points with two Unicode scalar values are allowed', () {
final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2290,7 +2290,7 @@ void main() { ...@@ -2290,7 +2290,7 @@ void main() {
test('Code points with more than three Unicode scalar values are not allowed', () { test('Code points with more than three Unicode scalar values are not allowed', () {
// |keyCode| and |scanCode| are arbitrary values. This test should fail due to an invalid |unicodeScalarValues|. // |keyCode| and |scanCode| are arbitrary values. This test should fail due to an invalid |unicodeScalarValues|.
void _createFailingKey() { void _createFailingKey() {
RawKeyEvent.fromMessage(const <String, dynamic>{ RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2305,7 +2305,7 @@ void main() { ...@@ -2305,7 +2305,7 @@ void main() {
}); });
test('Control keyboard keys are correctly translated', () { test('Control keyboard keys are correctly translated', () {
final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2321,7 +2321,7 @@ void main() { ...@@ -2321,7 +2321,7 @@ void main() {
}); });
test('Modifier keyboard keys are correctly translated', () { test('Modifier keyboard keys are correctly translated', () {
final RawKeyEvent shiftLeftKeyEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent shiftLeftKeyEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2336,7 +2336,7 @@ void main() { ...@@ -2336,7 +2336,7 @@ void main() {
}); });
test('data.toString', () { test('data.toString', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2349,7 +2349,7 @@ void main() { ...@@ -2349,7 +2349,7 @@ void main() {
}); });
test('data.equality', () { test('data.equality', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2366,7 +2366,7 @@ void main() { ...@@ -2366,7 +2366,7 @@ void main() {
isDown: true, isDown: true,
)); ));
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2383,7 +2383,7 @@ void main() { ...@@ -2383,7 +2383,7 @@ void main() {
isDown: true, isDown: true,
)))); ))));
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'linux', 'keymap': 'linux',
'toolkit': 'gtk', 'toolkit': 'gtk',
...@@ -2410,7 +2410,7 @@ void main() { ...@@ -2410,7 +2410,7 @@ void main() {
test('modifier keys are recognized individually', () { test('modifier keys are recognized individually', () {
for (final int modifier in modifierTests.keys) { for (final int modifier in modifierTests.keys) {
final RawKeyEvent event = RawKeyEvent.fromMessage(<String, dynamic>{ final RawKeyEvent event = RawKeyEvent.fromMessage(<String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'RandomCode', 'code': 'RandomCode',
...@@ -2441,7 +2441,7 @@ void main() { ...@@ -2441,7 +2441,7 @@ void main() {
// No need to combine meta key with itself. // No need to combine meta key with itself.
continue; continue;
} }
final RawKeyEvent event = RawKeyEvent.fromMessage(<String, dynamic>{ final RawKeyEvent event = RawKeyEvent.fromMessage(<String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'RandomCode', 'code': 'RandomCode',
...@@ -2469,7 +2469,7 @@ void main() { ...@@ -2469,7 +2469,7 @@ void main() {
}); });
test('Printable keyboard keys are correctly translated', () { test('Printable keyboard keys are correctly translated', () {
final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'KeyA', 'code': 'KeyA',
...@@ -2484,7 +2484,7 @@ void main() { ...@@ -2484,7 +2484,7 @@ void main() {
}); });
test('Control keyboard keys are correctly translated', () { test('Control keyboard keys are correctly translated', () {
final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'Escape', 'code': 'Escape',
...@@ -2499,7 +2499,7 @@ void main() { ...@@ -2499,7 +2499,7 @@ void main() {
}); });
test('Modifier keyboard keys are correctly translated', () { test('Modifier keyboard keys are correctly translated', () {
final RawKeyEvent shiftKeyEvent = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent shiftKeyEvent = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'ShiftLeft', 'code': 'ShiftLeft',
...@@ -2514,7 +2514,7 @@ void main() { ...@@ -2514,7 +2514,7 @@ void main() {
}); });
test('Arrow keys from a keyboard give correct physical key mappings', () { test('Arrow keys from a keyboard give correct physical key mappings', () {
final RawKeyEvent arrowKeyDown = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent arrowKeyDown = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'ArrowDown', 'code': 'ArrowDown',
...@@ -2529,7 +2529,7 @@ void main() { ...@@ -2529,7 +2529,7 @@ void main() {
}); });
test('Unrecognized keys are mapped to Web plane', () { test('Unrecognized keys are mapped to Web plane', () {
final RawKeyEvent arrowKeyDown = RawKeyEvent.fromMessage(const <String, dynamic>{ final RawKeyEvent arrowKeyDown = RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'Unrecog1', 'code': 'Unrecog1',
...@@ -2548,7 +2548,7 @@ void main() { ...@@ -2548,7 +2548,7 @@ void main() {
}); });
test('data.toString', () { test('data.toString', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'KeyA', 'code': 'KeyA',
...@@ -2559,7 +2559,7 @@ void main() { ...@@ -2559,7 +2559,7 @@ void main() {
'RawKeyEventDataWeb#00000(code: KeyA, key: a, location: 2, metaState: 16)')); 'RawKeyEventDataWeb#00000(code: KeyA, key: a, location: 2, metaState: 16)'));
// Without location // Without location
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'KeyA', 'code': 'KeyA',
...@@ -2570,7 +2570,7 @@ void main() { ...@@ -2570,7 +2570,7 @@ void main() {
}); });
test('data.equality', () { test('data.equality', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'KeyA', 'code': 'KeyA',
...@@ -2584,7 +2584,7 @@ void main() { ...@@ -2584,7 +2584,7 @@ void main() {
metaState: 0x10, metaState: 0x10,
)); ));
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, Object?>{
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'KeyA', 'code': 'KeyA',
...@@ -2610,6 +2610,6 @@ Future<void> _runWhileOverridingOnError(AsyncCallback body, {required FlutterExc ...@@ -2610,6 +2610,6 @@ Future<void> _runWhileOverridingOnError(AsyncCallback body, {required FlutterExc
Map<String, DiagnosticsNode> _groupDiagnosticsByName(Iterable<DiagnosticsNode> infos) { Map<String, DiagnosticsNode> _groupDiagnosticsByName(Iterable<DiagnosticsNode> infos) {
return Map<String, DiagnosticsNode>.fromIterable( return Map<String, DiagnosticsNode>.fromIterable(
infos, infos,
key: (dynamic node) => (node as DiagnosticsNode).name ?? '', key: (Object? node) => (node! as DiagnosticsNode).name ?? '',
); );
} }
...@@ -688,8 +688,8 @@ class KeyEventSimulator { ...@@ -688,8 +688,8 @@ class KeyEventSimulator {
result.complete(false); result.complete(false);
return; return;
} }
final Map<String, dynamic> decoded = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, dynamic>; final Map<String, Object?> decoded = SystemChannels.keyEvent.codec.decodeMessage(data)! as Map<String, dynamic>;
result.complete(decoded['handled'] as bool); result.complete(decoded['handled']! as bool);
} }
); );
return result.future; return result.future;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment