Unverified Commit 047bd6ce authored by 林洵锋's avatar 林洵锋 Committed by GitHub

Fix the character field of RawKeyEvent is always null on iOS (#135100)

Fixes https://github.com/flutter/flutter/issues/133956
parent 2d2049a1
...@@ -356,6 +356,10 @@ abstract class RawKeyEvent with Diagnosticable { ...@@ -356,6 +356,10 @@ abstract class RawKeyEvent with Diagnosticable {
keyCode: message['keyCode'] as int? ?? 0, keyCode: message['keyCode'] as int? ?? 0,
modifiers: message['modifiers'] as int? ?? 0, modifiers: message['modifiers'] as int? ?? 0,
); );
final Object? characters = message['characters'];
if (characters is String && characters.isNotEmpty) {
character = characters;
}
case 'linux': case 'linux':
final int unicodeScalarValues = message['unicodeScalarValues'] as int? ?? 0; final int unicodeScalarValues = message['unicodeScalarValues'] as int? ?? 0;
data = RawKeyEventDataLinux( data = RawKeyEventDataLinux(
......
...@@ -19,7 +19,7 @@ class _ModifierCheck { ...@@ -19,7 +19,7 @@ class _ModifierCheck {
void main() { void main() {
group('RawKeyboard', () { group('RawKeyboard', () {
testWidgetsWithLeakTracking('The correct character is produced', (WidgetTester tester) async { testWidgetsWithLeakTracking('The correct character is produced', (WidgetTester tester) async {
for (final String platform in <String>['linux', 'android', 'macos', 'fuchsia', 'windows']) { for (final String platform in <String>['linux', 'android', 'macos', 'fuchsia', 'windows', 'ios']) {
String character = ''; String character = '';
void handleKey(RawKeyEvent event) { void handleKey(RawKeyEvent event) {
expect(event.character, equals(character), reason: 'on $platform'); expect(event.character, equals(character), reason: 'on $platform');
...@@ -34,7 +34,7 @@ void main() { ...@@ -34,7 +34,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('No character is produced for non-printables', (WidgetTester tester) async { testWidgetsWithLeakTracking('No character is produced for non-printables', (WidgetTester tester) async {
for (final String platform in <String>['linux', 'android', 'macos', 'fuchsia', 'windows', 'web']) { for (final String platform in <String>['linux', 'android', 'macos', 'fuchsia', 'windows', 'web', 'ios']) {
void handleKey(RawKeyEvent event) { void handleKey(RawKeyEvent event) {
expect(event.character, isNull, reason: 'on $platform'); expect(event.character, isNull, reason: 'on $platform');
} }
......
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