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 did not 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 (via TextInputStyle) supports these properties, ensuring the system input is synchronized with the rendered text.

Migration guide

#

Authors of custom text input clients should 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: TBD
In stable release: Not yet

References

#

Relevant PR:

Relevant issues: