Skip to main content

Deprecate TextInputConnection.setStyle

The `TextInputConnection.setStyle` method has been deprecated in favor of the `TextInputConnection.updateStyle` method.

Summary

#

TextInputConnection.setStyle is deprecated in favor of TextInputConnection.updateStyle, which supports synchronizing letterSpacing, wordSpacing, and lineHeight to the engine.

Context

#

The previous setStyle method didn't support letterSpacing, wordSpacing, or lineHeight. This caused visual misalignment of the selection highlight and IME caret when these properties were used.

The replacement updateStyle method uses TextInputStyle to support these properties, ensuring the system input is synchronized with the rendered text.

Migration guide

#

If you author a custom text input client, replace calls to TextInputConnection.setStyle with TextInputConnection.updateStyle.

Code before migration

#
dart
connection.setStyle(
  fontFamily: 'Roboto',
  fontSize: 14.0,
  fontWeight: FontWeight.normal,
  textDirection: TextDirection.ltr,
  textAlign: TextAlign.start,
);

Code after migration

#
dart
connection.updateStyle(
  TextInputStyle(
    fontFamily: 'Roboto',
    fontSize: 14.0,
    fontWeight: FontWeight.normal,
    textDirection: TextDirection.ltr,
    textAlign: TextAlign.start,
    letterSpacing: 1.2,
    wordSpacing: 1.0,
    lineHeight: 1.5,
  ),
);

Timeline

#

Landed in version: 3.43.0-0.1.pre
In stable release: 3.44

References

#

Relevant PR:

Relevant issues: