attach method

  1. @override
void attach(
  1. TextEditingValue textEditingValue,
  2. TextInputConfiguration configuration
)

Updates the TextEditingValue of the text currently being edited.

Note that if there are IME-related requirements, please config composing value within TextEditingValue

BuildContext is used to get current keyboard appearance(light or dark)

Implementation

@override
void attach(
  TextEditingValue textEditingValue,
  TextInputConfiguration configuration,
) {
  if (_textInputConnection == null ||
      _textInputConnection!.attached == false) {
    _textInputConnection = TextInput.attach(
      this,
      configuration,
    );
  }

  final formattedValue = textEditingValue.format();
  _textInputConnection!
    ..setEditingState(formattedValue)
    ..show();
  currentTextEditingValue = formattedValue;

  Log.input.debug(
    'attach text editing value: $textEditingValue',
  );
}