-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[text_input] prepare for custom text input sources #72803
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
[text_input] prepare for custom text input sources #72803
Conversation
855ca1b
to
4590fc3
Compare
Rebased again in hopes to pass the CI (unrelated git fetch failures on macOS). |
The existing TextInputConnection class has been made abstract and method channel-agnostic. There is now a separate internal class, _TextInputChannelConnection, that implements the default type of text input connection that communicates with platform plugins via the text input system channel. The main motivation of the separation is to allow custom text input sources that can replace the method channel-based implementation and for example, communicate with an in-app virtual keyboard on (embedded) platforms that do not have a keyboard provided by the system Ref: flutter#68988
4590fc3
to
138e868
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting this out from #69146, should be easier to review and merge.
It looks like this could hypothetically break someone that was subclassing TextInputConnection. Do we know if anyone might be doing that? I've submitted this PR to have the internal Google tests run on it, and if it passes there then I'm more confident that it's not a problem.
CC @LongCatIsLooong since you reviewed #69146.
Thanks for the review!
I believe it's not a breaking change because the constructor was private before, so it wasn't possible to create a |
Ah I missed that, you're right! Should be fine then. I'm on board once all the tests pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I'll wait for @LongCatIsLooong's final approval.
Later on, _TextInputSource will be made public, abstract and documented so that it can be used as a base class for custom input sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
static MethodChannel? _channel; | ||
|
||
static void setChannel(MethodChannel newChannel) { | ||
_channel = newChannel..setMethodCallHandler(_handleTextInputInvocation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we call clean up on the previous channel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used in tests for setting up a testable environment via @visibleForTesting TextInput.setChannel()
. This will be moved to the upcoming private default implementation of TextInputSource
so it won't be visible to the outside.
Is the Google testing failure somehow related to this? |
Doesn't seem to be the case. I have restarted the test. |
The failure seems to be caused by something irrelevant. Could you rebase the branch to the latest commit and see if the failure goes away? |
Unrelated Mac build_tests failure. Let's try again. |
d51a018
to
6edb588
Compare
This reverts commit b73722b.
Description
The existing
TextInputConnection
class has been made abstract and method channel-agnostic. There is now a separate internal class,_TextInputChannelConnection
, that implements the default type of text input connection that communicates with platform plugins via the text input system channel.The main motivation of the separation is to allow custom text input sources that can replace the method channel-based implementation and for example, communicate with an in-app virtual keyboard on (embedded) platforms that do not have a system-provided keyboard.
To be able to eliminate direct method channel calls from the
TextInput
class, the following new methods have been introduced:TextInput.detach()
TextInput.reset()
TextInputConnection.hide()
TextInputConnection.setClient()
TextInputConnection.clearClient()
Consequently, the following methods have been deprecated:
TextInputConnection.close()
in favor ofTextInput.detach()
TextInputConnection.connectionClosedReceived()
in favor ofTextInput.reset()
Related PRs
This PR was split off from #69146.
Related Issues
#68988
Tests
I added the following tests:
test/services/text_input_test.dart
:Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.