# Deprecate `SemanticsProperties.focusable` and `SemanticsConfiguration.isFocusable`

> The `focusable` parameter has been replaced by `isFocused`.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


## Summary

The `SemanticsProperties.focusable` and `SemanticsConfiguration.isFocusable`
parameters were deprecated in favor of the `SemanticsProperties.focused` and
`SemanticsConfiguration.isFocused` parameters.

The `focused` parameter is now nullable.
Setting it to `true` or `false` automatically
sets `isFocusable` to `true`, while
setting it to `null` sets `isFocusable` to `false`.

## Context

The `SemanticsConfiguration.isFocusable` property is a boolean that
indicates whether the semantics node can have input focus.
`SemanticsConfiguration.isFocused` is a boolean that indicates if the
semantics node has input focus.

This change also applies to
`SemanticsProperties.focusable` and `SemanticsProperties.focused`.

We deprecated `isFocusable` because its functionality is covered by `isFocused`.
The `isFocused` property is now stored as a tristate flag in the engine,
and this change makes the framework consistent with the engine.

## Description of change

The `SemanticsConfiguration.isFocusable` property is
deprecated in favor of `SemanticsConfiguration.isFocused`.
This property is a nullable boolean; setting it to `true` or `false`
automatically sets `isFocusable` to `true`, and
setting it to `null` sets `isFocusable` to `false`.

## Migration guide

Replace `SemanticsConfiguration.isFocusable` with
`SemanticsConfiguration.isFocused`.

### Example 1: Setting `isFocused` to `true` automatically sets `isFocusable` to `true`

Code before migration:

```dart
void describeSemanticsConfiguration(SemanticsConfiguration config) {
  config.isFocusable = true;
  config.isFocused = true;
}
```

Code after migration:

```dart
void describeSemanticsConfiguration(SemanticsConfiguration config) {
  config.isFocused = true;
}
```

### Example 2: Setting `isFocused` to `null` automatically sets `isFocusable` to `false`

Code before migration:

```dart
void describeSemanticsConfiguration(SemanticsConfiguration config) {
  config.isFocusable = false;
  config.isFocused = false;
}
```

Code after migration:

```dart
void describeSemanticsConfiguration(SemanticsConfiguration config) {
  config.isFocused = null;
}
```


## Timeline

Landed in version: 3.37.0-0.0.pre<br>
In stable release: 3.38


## References

API documentation:

* [`SemanticsConfiguration`][]
* [`SemanticsProperties`][]
* [`SemanticsNode`][]

Relevant issue:

* [Issue 166092][]

Relevant PR:

* [PR 170935][]

[`SemanticsConfiguration`]: https://api.flutter-io.cn/flutter/semantics/SemanticsConfiguration-class.html
[`SemanticsProperties`]: https://api.flutter-io.cn/flutter/semantics/SemanticsProperties-class.html
[`SemanticsNode`]: https://api.flutter-io.cn/flutter/semantics/SemanticsNode-class.html
[Issue 166092]: https://github.com/flutter/flutter/issues/166092
[PR 170935]: https://github.com/flutter/flutter/pull/170935

