Skip to content

Commit 0e8ffc6

Browse files
Don't use 'ios' platform when typing on keyboard due to Flutter bug (#16)
1 parent d532f16 commit 0e8ffc6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/src/keyboard.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,27 @@ extension KeyboardInput on WidgetTester {
2424
/// `TextField` only responds to the IME, so this method would have no
2525
/// effect on a `TextField`.
2626
Future<void> typeKeyboardText(String plainText) async {
27+
// Avoid generating characters with an "ios" platform due to Flutter bug.
28+
// TODO: Remove special platform selection when Flutter issue is solved (https://github.com/flutter/flutter/issues/133956)
29+
final platform = _keyEventPlatform != "ios" ? _keyEventPlatform : "android";
30+
2731
for (int i = 0; i < plainText.length; i += 1) {
2832
final character = plainText[i];
2933
final keyCombo = _keyComboForCharacter(character);
3034

3135
if (keyCombo.isShiftPressed) {
32-
await sendKeyDownEvent(LogicalKeyboardKey.shift, platform: _keyEventPlatform);
36+
await sendKeyDownEvent(LogicalKeyboardKey.shift, platform: platform);
3337
}
3438

3539
if (keyCombo.isShiftPressed) {
36-
await sendKeyDownEvent(keyCombo.physicalKey!, platform: _keyEventPlatform, character: character);
37-
await sendKeyUpEvent(keyCombo.physicalKey!, platform: _keyEventPlatform);
40+
await sendKeyDownEvent(keyCombo.physicalKey!, platform: platform, character: character);
41+
await sendKeyUpEvent(keyCombo.physicalKey!, platform: platform);
3842
} else {
39-
await sendKeyEvent(keyCombo.key, platform: _keyEventPlatform);
43+
await sendKeyEvent(keyCombo.key, platform: platform);
4044
}
4145

4246
if (keyCombo.isShiftPressed) {
43-
await sendKeyUpEvent(LogicalKeyboardKey.shift, platform: _keyEventPlatform);
47+
await sendKeyUpEvent(LogicalKeyboardKey.shift, platform: platform);
4448
}
4549

4650
await pump();

0 commit comments

Comments
 (0)