TextInput class

An low-level interface to the system's text input control.

To start interacting with the system's text input control, call attach to establish a TextInputConnection between the system's text input control and a TextInputClient. The majority of commands available for interacting with the text input control reside in the returned TextInputConnection. The communication between the system text input and the TextInputClient is asynchronous.

The platform text input plugin (which represents the system's text input) and the TextInputClient usually maintain their own text editing states (TextEditingValue) separately. They must be kept in sync as long as the TextInputClient is connected. The following methods can be used to send TextEditingValue to update the other party, when either party's text editing states change:

When synchronizing the TextEditingValues, the communication may get stuck in an infinite when both parties are trying to send their own update. To mitigate the problem, only TextInputClients are allowed to alter the received TextEditingValues while platform text input plugins are to accept the received TextEditingValues unmodified. More specifically:

  • When a TextInputClient receives a new TextEditingValue from the platform text input plugin, it's allowed to modify the value (for example, apply TextInputFormatters). If it decides to do so, it must send the updated TextEditingValue back to the platform text input plugin to keep the TextEditingValues in sync.

  • When the platform text input plugin receives a new value from the connected TextInputClient, it must accept the new value as-is, to avoid sending back an updated value.

See also:

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scribbleInProgress bool
Returns true if a scribble interaction is currently happening.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

scribbleClients Map<String, ScribbleClient>
Used for testing within the Flutter SDK to get the currently registered ScribbleClient list.
no setter

Static Methods

attach(TextInputClient client, TextInputConfiguration configuration) TextInputConnection
Begin interacting with the text input control.
ensureInitialized() → void
Ensure that a TextInput instance has been set up so that the platform can handle messages on the text input method channel.
finishAutofillContext({bool shouldSave = true}) → void
Finishes the current autofill context, and potentially saves the user input for future use if shouldSave is true.
registerScribbleElement(String elementIdentifier, ScribbleClient scribbleClient) → void
Registers a ScribbleClient with elementIdentifier that can be focused by the engine.
restorePlatformInputControl() → void
Restores the default platform text input control.
setChannel(MethodChannel newChannel) → void
Set the MethodChannel used to communicate with the system's text input control.
setInputControl(TextInputControl? newControl) → void
Sets the current text input control.
unregisterScribbleElement(String elementIdentifier) → void
Unregisters a ScribbleClient with elementIdentifier.
updateEditingValue(TextEditingValue value) → void
Updates the editing value of the attached input client.