-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Add support/enablers for custom/in-app virtual keyboards #68988
Copy link
Copy link
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Fluttercustomer: dream (g3)frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Fluttercustomer: dream (g3)frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Use case
Flutter should make it possible to override the default text input control.
The default text input control is hard-wired to a method channel that is used to communicate with the platform plugin. However, on embedded systems that do not have a system-wide virtual keyboard, it should be possible for an in-app virtual keyboard to register itself so that it can take over the text input communication.
Proposal
In essence, an in-app VKB should be allowed to:
a) intercept text input calls (respective to
'TextInput.xxx') from Flutter, andb) provide text input responses (respective to
'TextInputClient.xxx') back to Flutter.This would be possible if there was a way to register a custom text input control that would override the default text input control. Notice, however, that even with custom text input controls it is important to keep some of the text input method channel communication intact to ensure that text input with e.g. physical keyboards continues to work.
Related packages
There is a basic
virtual_keyboardpackage on pub.dev. Notice that it's just a widget with a callback for key presses. Since it has no way to integrate with Flutter and specificallyTextField, the example is simply collecting key presses into aTextlabel and has a toggle button to tell the VKB whether it should present a textual or a numeric mode. While this approach "works" for a trivial single page example, it does not really scale that well for real-life apps with multiple screens and input fields.Proof of concept
I have made a proof of concept implementation based on the above proposal and the
virtual_keyboardpackage. Here's a video that shows it in action, running with flutter-pi on a Raspberry Pi 4: https://www.youtube.com/watch?v=zgiiThQCU1E