Fix the character field of RawKeyEvent is always null on iOS (#135100)
Fixes https://github.com/flutter/flutter/issues/133956
This commit is contained in:
parent
2d2049a17c
commit
047bd6cebd
@ -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 {
|
|||||||
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() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user