The Visibility widget is no longer focusable by default when maintainState is enabled
Summary
#This change was introduced to fix an issue where an IndexedStack
s hidden children would be focusable with keyboard events (see issue) due to the underlying Visibility
widgets default behavior.
Description of change
#The core change is the Visibility
widget is no longer focusable by default when maintainState
is enabled. A new flag, maintainFocusability
, must be set to true with maintainState
for a hidden widget to remain focusable.
Migration guide
#If your app has a Visibility
widget that does not set maintainState
to true, then no changes are required.
If your app has a Visibility
widget that sets maintainState
to true and you relied on the previous default behavior that allowed you to focus your hidden widget, you will need to set maintainFocusability
to true.
Code before migration:
child: Visibility(
maintainState: true,
child: SomeWidget(),
)
Code after migration:
child: Visibility(
maintainState: true,
maintainFocusability: true,
child: SomeWidget(),
)
Timeline
#Landed in version: 3.34.0-pre
In stable release: 3.35
References
#API documentation:
Relevant issues:
Relevant PRs:
Unless stated otherwise, the documentation on this site reflects the latest stable version of Flutter. Page last updated on 2025-10-02. View source or report an issue.