updateEditingValue method Null safety

void updateEditingValue(
  1. TextEditingValue value
)

Simulates the user changing the TextEditingValue to the given value.

To update the UI under test after this method is invoked, use WidgetTester.pump.

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.

See also:

  • enterText, which is similar but takes only a String and resets the selection.

Implementation

void updateEditingValue(TextEditingValue value) {
  TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
    SystemChannels.textInput.name,
    SystemChannels.textInput.codec.encodeMethodCall(
      MethodCall(
        'TextInputClient.updateEditingState',
        <dynamic>[_client ?? -1, value.toJSON()],
      ),
    ),
    (ByteData? data) { /* ignored */ },
  );
}