Flutter 3.41 is live! Check out theFlutter 3.41 blog post!
The Visibility widget is no longer focusable by default when maintainState is enabled
The Visibility widget by default no longer implicitly retains focusability for its child when maintainState is enabled.
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.
Thebreaking change index file lists the docs created for each release.
Summary
# This change was introduced to fix an issue where anIndexedStacks hidden children would be focusable with keyboard events (seeissue) due to the underlyingVisibility widgets default behavior.
Description of change
# The core change is theVisibility widget is no longer focusable by default whenmaintainState is enabled. A new flag,maintainFocusability, must be set to true withmaintainState for a hidden widget to remain focusable.
Migration guide
# If your app has aVisibility widget that does not setmaintainState to true, then no changes are required.
If your app has aVisibility widget that setsmaintainState to true and you relied on the previous default behavior that allowed you to focus your hidden widget, you will need to setmaintainFocusability 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 Flutter 3.38.6. Page last updated on 2025-10-30.View source orreport an issue.