Deprecate `SemanticsProperties.focusable` and `SemanticsConfiguration.isFocusable`
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, and
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:
void describeSemanticsConfiguration(SemanticsConfiguration config) {
config.isFocusable = true;
config.isFocused = true;
}Code after migration:
void describeSemanticsConfiguration(SemanticsConfiguration config) {
config.isFocused = true;
}Example 2: setting isFocused to null automatically sets isFocusable to false.
#Code before migration:
void describeSemanticsConfiguration(SemanticsConfiguration config) {
config.isFocusable = false;
config.isFocused = false;
}Code after migration:
void describeSemanticsConfiguration(SemanticsConfiguration config) {
config.isFocused = null;
}Timeline
#Landed in version: 3.37.0-0.0.pre In stable release: Not yet
References
#API documentation:
Relevant issue:
Relevant PR:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2025-09-25。 查看文档源码 或者 为本页面内容提出建议.