closeConnection method
Simulates the user closing the text input connection.
For example:
- User pressed the home button and sent the application to background.
- User closed the virtual keyboard.
This can be called even if the TestTextInput has not been registered.
If this is used to inject text when there is a real IME connection, for example when using the integration_test library, there is a risk that the real IME will become confused as to the current state of input.
Implementation
void closeConnection() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall(
MethodCall(
'TextInputClient.onConnectionClosed',
<dynamic>[_client ?? -1],
),
),
(ByteData? data) { /* response from framework is discarded */ },
);
}