Deprecated TextField.canRequestFocus
Summary
#
                  TextField.canRequestFocus is deprecated.
                  The same functionality can be achieved by setting the
                  canRequestFocus parameter of the TextField's FocusNode.
                
Background
#
                  TextField.canRequestFocus was added to support DropdownMenu, which
                  has a TextField that sometimes isn't interactive. However, the same
                  functionality can be achieved by setting the canRequestFocus parameter of a
                  TextField's FocusNode. DropdownMenu has been migrated to this approach,
                  and other use cases should follow the same pattern.
                
                  Apps that use TextField.canRequestFocus display the following error when run
                  in debug mode: "Use focusNode instead.". Specifically, this means that users
                  should pass a FocusNode to TextField.focusNode with the
                  FocusNode.canRequestFocus parameter set.
                
Migration guide
#
                  To migrate, remove the TextField.canRequestFocus parameter. Create a
                  FocusNode with the FocusNode.canRequestFocus parameter set to the desired
                  value, and pass that to TextField.focusNode.
                
Code before migration:
class _MyWidgetState extends State<MyWidget> {
  @override
  Widget build(BuildContext context) {
    return TextField(
      canRequestFocus: false,
    );
  }
}
                    
                    
                    
                  Code after migration:
class _MyWidgetState extends State<MyWidget> {
  final FocusNode _focusNode = FocusNode(canRequestFocus: false);
  @override
  Widget build(BuildContext context) {
    return TextField(
      focusNode: _focusNode,
    );
  }
}
                    
                    
                    
                  Timeline
#
                  Landed in version: Reverted, waiting to reland
                  In stable release: Not yet
                
References
#API documentation:
Relevant issues:
Relevant PRs:
Unless stated otherwise, the documentation on this site reflects Flutter 3.35.5. Page last updated on 2025-10-28. View source or report an issue.