📜  nodeFocus flutter - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:08.405000             🧑  作者: Mango

代码示例1
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, ...);
}