Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
title: Deprecate `TextInputConnection.setStyle`
description: >-
The `TextInputConnection.setStyle` method has been deprecated in favor
of the `TextInputConnection.updateStyle` method.
---

{% render "docs/breaking-changes.md" %}

## 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<br>
In stable release: Not yet

## References

Relevant PR:

* [PR 180436][]

Relevant issues:

* [Issue 161592][]

<!-- Stable channel link: -->
[PR 180436]: {{site.repo.flutter}}/pull/180436
[Issue 161592]: {{site.repo.flutter}}/issues/161592
2 changes: 2 additions & 0 deletions src/content/release/breaking-changes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ They're sorted by release and listed in alphabetical order:
* [`FontWeight` also controls the weight attribute of variable fonts][]
* [Deprecate `containsSemantics` in favor of `isSemantics`][]
* [Deprecate `findChildIndexCallback` in favor of `findItemIndexCallback` in `ListView` and `SliverList` separated constructors][]
* [Deprecate `TextInputConnection.setStyle`][]
* [Migrating Flutter Android app to Android Gradle Plugin 9.0.0][]
* [Material 3 tokens update][]
* [Page transition builders reorganization][]
Expand All @@ -51,6 +52,7 @@ They're sorted by release and listed in alphabetical order:
[`FontWeight` also controls the weight attribute of variable fonts]: /release/breaking-changes/font-weight-variation
[Deprecate `containsSemantics` in favor of `isSemantics`]: /release/breaking-changes/deprecate-contains-semantics
[Deprecate `findChildIndexCallback` in favor of `findItemIndexCallback` in `ListView` and `SliverList` separated constructors]: /release/breaking-changes/separated-builder-find-child-index-callback
[Deprecate `TextInputConnection.setStyle`]: /release/breaking-changes/deprecate-text-input-connection-set-style
[Migrating Flutter Android app to Android Gradle Plugin 9.0.0]: /release/breaking-changes/migrate-to-agp-9
[Material 3 tokens update]: /release/breaking-changes/material-color-utilities

Expand Down