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]):
/// ///
......
...@@ -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