Asked
Active
Viewed 48 times
-2
-
1Hello, please refrain from posting screenshots of your code. It is better that you directly put it here so that the community could reproduce it and help you with your issue. Since you're new, here's a guide in [How to Ask](https://stackoverflow.com/questions/how-to-ask) questions here and also a guide for posting [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that could help you in your next questions here. – Yrll Sep 28 '22 at 05:51
1 Answers
-1
You can use FocuseNode
in your Textfield
something like this:
FocusNode focusNode;
void initState() {
focusNode = new FocusNode();
// listen to focus changes
focusNode.addListener(() => print('focusNode updated: hasFocus: ${focusNode.hasFocus}'));
}
void setFocus() {
FocusScope.of(context).requestFocus(focusNode);
}
Widget build() {
return
...
new TextField(focusNode: focusNode, ...);
}

aminjafari-dev
- 264
- 1
- 17