Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulate IME messages when pressing ENTER (Resolves #19) #20

Merged

Conversation

angelosilvestre
Copy link
Collaborator

When a widget is attached to the IME, if a ENTER key press isn't handled, the IME generates a \n followed by a TextInputAction.newline.

This PR adds the methods pressEnterWithIme and pressNumpadEnterWithIme to simulate these messages.

@@ -81,7 +82,40 @@ extension KeyboardInput on WidgetTester {

Future<void> pressEnter() async {
await sendKeyEvent(LogicalKeyboardKey.enter, platform: _keyEventPlatform);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that you removed this pumpAndSettle()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed by mistake.

lib/src/keyboard.dart Outdated Show resolved Hide resolved
}

await ime.typeText('\n', finder: finder, getter: getter);
await pump();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these actions actually separated by a frame in the real Flutter implementation? Or do they happen in the same frame?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They happen in the same frame. Updated.

lib/src/keyboard.dart Outdated Show resolved Hide resolved
lib/src/keyboard.dart Outdated Show resolved Hide resolved
lib/src/keyboard.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@matthew-carroll matthew-carroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matthew-carroll matthew-carroll merged commit e070688 into Flutter-Bounty-Hunters:main Oct 1, 2023
1 check passed
@angelosilvestre angelosilvestre deleted the enter_with_ime branch October 1, 2023 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants