I have a TextField with a focusNode that suddenly stops gaining focus after changing screens.
One thing I notice though, the object changes its value canRequestFocus to false for no reason.
FocusNode value before launching other Widget:
FocusNode#1502a(context: EditableText-[LabeledGlobalKey<EditableTextState>#26e29])
FocusNode value after launching other Widget and TextField doesn't get focus when I tap:
FocusNode#1502a(context: EditableText-[LabeledGlobalKey<EditableTextState>#26e29], NOT FOCUSABLE)
The problem doesn't happen on Android.
I've created this Sample Project and this Video showing how to reproduce the issue.
I encountered the same issue today, with Flutter version 3.22.1. My solution was to use a custom subclass of FocusNode to create the focus node:
class _FocusNode extends FocusNode {
@override
bool get canRequestFocus => true;
}
This overrides the problematic variable, and makes the text field always focusable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With